Sunday, January 10, 2010

In terms of code generation, how do the two definitions of buf, both presented above, differ?

char buf [] = "Hello world!";
char * buf = "Hello world!";

a) The first definition certainly allows the contents of buf to be safely modified at runtime; the second definition does not
b) The first definition is not suitable for usage as an argument to a function call; the second definition is
c) The first definition is not legal because it does not indicate the size of the array to be allocated; the second definition is legal
d) They do not differ -- they are functionally equivalent
e) The first definition does not allocate enough space for a terminating NUL-character, nor does it append one; the second definition does

No comments: