Here is the code that has a function GetString, this returns a char pointer. This char pointer is pointing to the string, which is in the stack. Now, why does the C compiler doesn't throw any warning when the address is returned for that string? Is the scope limited? Is it really a problem? Is "Hello" stored in Data Segment?
#include <stdio.h>
#include <string.h>
char * GetString()
{
char *Hello = "Hello";
return Hello;
}
int main(void)
{
printf("%s",GetString());
return 0;
}