Possible Duplicate:
How are string literals compiled in C?
I wrote the small code below. In this code, I think the address of first and second "hello" string would be compared. I am confused in this. In first look, I thought that both the strings would be stored in Read only memory and thus would have different address. But "equal" got printed after the execution.
When I saw the objdump, I was not not able to see the string hello. I understand that I have not taken a variable to store them, but where would "hello" be stored.
Will it be stored on STACK ?? or Will it be stored on Code Segment ??
#include<stdio.h>
int main()
{
if ("hello" == "hello")
printf("\n equal ");
else
printf("\n not equal");
return 0;
}
When I changed the if condition to if ("hello" == "hell1")
, "not equal" got printed.
Again, where and how are the strings getting stored.
Will it be stored on STACK ??
or
Will it be stored on Code Segment ??
I would really appreciate if someone here gives me en elaborate answer. Thanks