Let's say I have this C
code
f((char []){ "hello" });
f((const char []){ "hello" });
f("hello");
In all three cases, a pointer to the first character of the char array is initialized as the function parameter.hello
is copied into the function.
I know that in C, the string literal corresponds to char []
while in C++ the string literal corresponds to const char []
, but will it create the same code as with char []
or const char []
?
In a C program, could you exchange all occurences of "string"
with (char []){ "string" }
and get the same result on the assembly level?