i m new to C Language
this is my code:
char* getString()
{
char s[] = "Will I be printed?";
return s;
}
int main()
{
printf("%s", getString());
getchar();
}
it showing warning that : function returns address of local variable
now when i code this :
char* getString()
{
char *s = "Will I be printed?";
return s;
}
int main()
{
printf("%s", getString());
getchar();
}
it will print the string : "Will I be printed?"
why is that? is it trur that both pointer and character array is LOCAL Variable and they stored in Stack..?
P.S i am using http://ide.geeksforgeeks.org/