Possible Duplicate:
What is the difference between char a[] = “string”; and char *p = “string”;
I read this question somewhere.
char buf[]="hello";
char *buf="hello";
In terms of code generation, how do the two definitions of buf, differ?
There were four options to this and I marked
The first definition certainly allows the contents to buf to be safely modified at runtie; the second definition does not.
But as it turns out, the quiz master had the following to be marked as correct.
They do no differ-- they are functionally equivalent
Why is my choice wrong, since I can not do buf[3]='t'
for the second case, but I can for the first one?
Thanks.