Given that these are allowed:
char c[] = "abc";
char c[] = {'a','b','c','\0'}
char *c = "abc";
Why then is this not allowed?
char *c = {'a','b','c','\0'}; // error: a char cannot initialize a char*
If a string literal is interpreted by the compiler as a null-terminated array of chars then I would have thought it equivalent to statement 3 above, no?
Similarly, why is this not allowed :
int arr[3];
int *i = arr; // OK
int *i = {1,2,3} // error: an int cannot initialize an int*
It's not a huge problem, I'm just curious.. I guess the question boils down to what's the difference between a string literal (or declared integer array) and an array of character elements when assigning to a pointer?