Hello,
I've got the following code:
Someone explained to me on IRC that string literals have static storage. So one would expect the preceding code to work. It however gives me a compiler error:Code:#include <stdio.h> void test(); int main() { test(); printf("%s",ptr); return 0; } void test() { char *ptr; ptr = "Hello!"; }
Could somebody clarify this for me?Code:testcase.c: In function ‘main’: testcase.c:7: error: ‘ptr’ undeclared (first use in this function)
Thank You



LinkBack URL
About LinkBacks





