[Solved] What does char *x = “geeksquiz” mean?


Does this mean that x holds the address of first element of the string,i.e, the character ‘g’ ?

Yes.

is it the placeholder %s that’s instructing the printf to print the string literals ?

Yes.

To be more specific, %s is not limited for string literals. It is for printing null terminated srings – which string literals are. Also, it’s called a format specifier.


Considering you’ve used the tag, note that the expression char *x = "geeksquiz"; is ill-formed in C++. In C++, the string literal is an array of const char and it doesn’t decay to a pointer to non-const char. It is well formed in C, because in that language string literals are non-const.

solved What does char *x = “geeksquiz” mean?