mercredi 22 avril 2015

Retrieve a global variable in C program

Suppose I have a C program foo.c which uses a global variable 'i'

int i;

foo(x){
  i = x*x;
}

Wihtout modifying the program foo.c, is there a mechanism in C/C++ for us retrieve the value of i for a given ‘x’, for example, by devising a C/C++ program that wraps foo.c like:

int foo2(x){
  foo(x);
  return the value of i stored in memory when computing foo(x);
}

Thanks for your ideas.

Aucun commentaire:

Enregistrer un commentaire