S
somenath
According to comp.lang.c FAQ list Question 1.32,
char *p = "string literal";
"string literal” is unnamed, static array of characters, and this unnamedarray may be stored in read-only memory, and which therefore cannot necessarily be modified. In an expression context, the array is converted at onceto a pointer, so declaration initializes p to point to the unnamed array's first element.
Then why we can not do the following?
char a[14];
a = "Hello, world!";
So using the above logic "Hello, world!" is unnamed, static array of characters, and this unnamed array may be stored in read-only memory, and which therefore cannot necessarily be modified. In an expression context, the array is converted at once to a pointer, so declaration initializes “a” which is ( except in case of operand of sizeof and & ) converted to pointer to the first element of char[14] i.e to &a[0].
So why the “a” can not be assigned to the pointer to the unnamed array's first element?
char *p = "string literal";
"string literal” is unnamed, static array of characters, and this unnamedarray may be stored in read-only memory, and which therefore cannot necessarily be modified. In an expression context, the array is converted at onceto a pointer, so declaration initializes p to point to the unnamed array's first element.
Then why we can not do the following?
char a[14];
a = "Hello, world!";
So using the above logic "Hello, world!" is unnamed, static array of characters, and this unnamed array may be stored in read-only memory, and which therefore cannot necessarily be modified. In an expression context, the array is converted at once to a pointer, so declaration initializes “a” which is ( except in case of operand of sizeof and & ) converted to pointer to the first element of char[14] i.e to &a[0].
So why the “a” can not be assigned to the pointer to the unnamed array's first element?