A few questions about char pointers.
Posted
by m4design
on Stack Overflow
See other posts from Stack Overflow
or by m4design
Published on 2010-06-02T19:16:49Z
Indexed on
2010/06/02
19:24 UTC
Read the original article
Hit count: 203
1- How does this work:
char *ptr = "hi";
Now the compiler will put this string in the memory (I'm guessing the stack), and create a pointer to it? Is this is how it works?
2- Also if it is created locally in a function, when the function returns will the memory occupied by the string be freed?
3- Last but not least, why is this not allowed: ptr[0] = 'H';
?
© Stack Overflow or respective owner