mercredi 8 février 2017

Is it ok to use a pointer which point to the address of a variable declared inside "if" statement

Is it ok to use a pointer which point to the address of a variable declared inside "if" statement ? Example as below:

...
int *pTest = 0;
if (...)
{
  int x = 10;
  pTest = &x;
}
else
{
  int x = 100;
  pTest = &x;
}
...
// use pTest 

Aucun commentaire:

Enregistrer un commentaire