please explain

strings are stored in memory as array of characters with a null charactera te the this statement
is this string being stored in memory.please give an example of this situation other than
char name[10]="hello";
Yes, "hello" is stored somewhere in memory. I don't know what kind of examples you want. You have already given examples.
You can write it like so:

const char *name="hello";
char name[]= {'h', 'e', 'l', 'l', 'o', '\0' };
Each string literal is stored in memory and whether two equal string literals will be stored as one literal or as two separate literals it is implementation defined and depends of the compiler options. So in general the result of the following comparision can be false or true depending on your compiler and its option.

if ( "Hello" == "Hello" ) std::cout << "They occupy the same memory\n";
else std::cout << "They are stored separatly\n";
Topic archived. No new replies allowed.