Possible Duplicate:
returning a local variable from function in C
The more I think about this, the less I am sure why this is not such a good idea... The compiler complains about having an auto variable from inside the function return to the caller. For instance:
char * foo() {
char bar[11];
fgets(bar, 10, stdin);
return bar;
}
Versus:
char bar[11];
char * foo() {
fgets(bar, 10, stdin);
return bar;
}
I am probably not making much sense. I don't quite understand the problem of having a pointer declaration inside, would the the caller simply not just assume the memory address?