In this question it was said in the comments:
char arr[10] = { 'H', 'e', 'l', 'l', 'o', '\0'};
andchar arr[10] = "Hello";
are strictly the same thing. – Michael Walz
This got me thinking.
I know that "Hello"
is string literal. String literals are stored with static storage duraction and are immutable.
But if both are are really the same then char arr[10] = { 'H', 'e', 'l', 'l', 'o', '\0'};
would also create a similar string literal with.
Does char b[10]= {72, 101, 108, 108, 111, 0};
also create a "string" literal with static storage duration? Because theoretically it is the same thing.
char a = 'a';
is the same thing aschar a; ...; a = 'a';
, so your thoughts are correct'a'
is simply written toa
Are there differences between:
char a = 'a';
char a = {'a'};
How/where are the differences defined?
EDIT: I see that I haven't made it clear enough that I am particularly interested in the memory usage/storage duration of the literals. I will leave the question as it is, but would like to make the emphasis of the question more clear in this edit.