P
polas
Good morning,
I have a quick question to clear up some confusion in my mind. I
understand that using a string literal in a declaration such as char
*p = "string literal" declares a pointer to memory holding the string
and the string might very well be held in read only memory.
However, I am sure that I read somewhere that the declaration char a[]
= "string literal", even though a is an array (and I understand the
differences between the two declarations), defines a such that it
might also be also held in read only memory and thus writing to
indexes of a might not work...
After some doubt about this popped into my mind, I have had a look
through the C faq and it seems to suggest that I am wrong - in the
second case one can use the array declared as above as normal, but I
would like to make sure.
Thanks,
Nick
I have a quick question to clear up some confusion in my mind. I
understand that using a string literal in a declaration such as char
*p = "string literal" declares a pointer to memory holding the string
and the string might very well be held in read only memory.
However, I am sure that I read somewhere that the declaration char a[]
= "string literal", even though a is an array (and I understand the
differences between the two declarations), defines a such that it
might also be also held in read only memory and thus writing to
indexes of a might not work...
After some doubt about this popped into my mind, I have had a look
through the C faq and it seems to suggest that I am wrong - in the
second case one can use the array declared as above as normal, but I
would like to make sure.
Thanks,
Nick