Hello,
Quick question about scope in C: if I have the following:
then there is no guarantee that *p == 1, since x is destroyed after the end of the code block.Code:int* p;
{
int x = 1;
p = &x;
}
//do something with p
However if I had:
would that have the same instability? If I had used malloc() instead, would that keep the value 'alive' in memory?Code:char* p;
{
char* x = "hello world";
p = x;
}
//do something with p
Thanks