J
jvh
A friend told me that he had read somewhere that giving pointers to an
average programmer is like giving a gun to a 6 year old. Since I got
the wrong answer for the problem below I must be an average
programmer.
I got this problem from cprogramming.com. Does it display 10 or 12 and
why?
void afunction(int *x)
{
x = new int;
*x = 12;
}
void main()
{
int v = 10;
afunction(&v);
cout << "\nv:" << v;
getchar();
}
Thanks,
jvh
average programmer is like giving a gun to a 6 year old. Since I got
the wrong answer for the problem below I must be an average
programmer.
I got this problem from cprogramming.com. Does it display 10 or 12 and
why?
void afunction(int *x)
{
x = new int;
*x = 12;
}
void main()
{
int v = 10;
afunction(&v);
cout << "\nv:" << v;
getchar();
}
Thanks,
jvh