R
rskeples
I write a small program.
char *foo(void);
char *a = "I like C";
int main(void) {
if((strcmp(a,foo())) {
printf("\n i like c");
}
}
char *foo(void)
{
char b[100] = "I like C";
return b;
}
My teacher tells me that this program not work since the return value
from function foo() is not guaranteed to be preserved. I think this is
correct usage of pointers.
I dont think so. I think my teacher wrong.
Please explain.
thanks you
Rick
char *foo(void);
char *a = "I like C";
int main(void) {
if((strcmp(a,foo())) {
printf("\n i like c");
}
}
char *foo(void)
{
char b[100] = "I like C";
return b;
}
My teacher tells me that this program not work since the return value
from function foo() is not guaranteed to be preserved. I think this is
correct usage of pointers.
I dont think so. I think my teacher wrong.
Please explain.
thanks you
Rick