S
sam_cit
Hi Everyone,
I have the following function,
char* sample1()
{
char *p = "india";
return(p);
}
//in this case the memory storing india is not destroyed at the end
of the function, indicating that it wasn't stored in the stack meant
for the function call.
However, the following function causes unexpected behavior as
expected ;-)
char* sample2()
{
char p[] = "india";
return(p);
}
I tried both the functions in Microsoft Visual C++ 6.0, is it
specified as per the standard that the first case be not stored in the
stack or is it implementation defined?
Thanks in advance!!!
I have the following function,
char* sample1()
{
char *p = "india";
return(p);
}
//in this case the memory storing india is not destroyed at the end
of the function, indicating that it wasn't stored in the stack meant
for the function call.
However, the following function causes unexpected behavior as
expected ;-)
char* sample2()
{
char p[] = "india";
return(p);
}
I tried both the functions in Microsoft Visual C++ 6.0, is it
specified as per the standard that the first case be not stored in the
stack or is it implementation defined?
Thanks in advance!!!