Do string constants persist out of scope?

Adam Kao adamk at mit-amt.MEDIA.MIT.EDU
Fri Jan 12 04:02:17 AEST 1990


If I define a string constant in a procedure and then pass it back
out, does the pointer I get remain valid?  I'm confused because
strings are really char pointers.  I tried it in a test program and it
worked, but I'm a little worried it might be accidental.  I guess what
I'm really asking is whether the compiler permanently allocates memory
for all the string constants in the whole program.

Thanks in advance,

Adam



More information about the Comp.lang.c mailing list