Hey,
I need a little help with pointers or maybe a good reference.
I have this code:
Code:
char *foo(char* temp){
return temp;
}
int main(int argc, char *argv[]){
char *bar[4];
bar[0] = foo("1");
bar[1] = foo("2");
bar[2] = foo("3");
bar[3] = foo("4");
printf("%s\n", bar[0]);
printf("%s\n", bar[1]);
printf("%s\n", bar[2]);
printf("%s\n", bar[3]);
return EXIT_SUCCESS;
}
the address of the temp variables is somewhere in the memory and could be overwritten right? As far as I know, the scope from temp ends on return and could be overwritten.