Is only in char *ptr = "Hello World" a string literal or are both "Hello World" string literals?
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char array[] = { "Hello World" };
char *ptr = "Hello World";
printf( "%s\n", array );
printf( "%s\n", ptr );
printf( "%c\n", *array );
printf( "%c\n", *ptr );
printf( "%c\n", array[1] );
printf( "%c\n", ptr[1] );
return EXIT_SUCCESS;
}
# Hello World
# Hello World
# H
# H
# e
# e
"Hello World"twice,"%s\n"also twice, and"%c\n"four times. If they occupy 8 distinct regions of memory or 3 (or anything in between) is unspecified by the Standard: implementations are free to do as they like.