If I declare and use a pointer like this:
int counter;
char *pCow = "pCow goes MOO";
for(counter = 0; counter < 14; counter++)
printf("%c", pCow[counter]);
it displays the entire string and works and yeah and there is much rejoicing.
However, if I use an initializer like this:
int counter;
char *pCow = {'p','C','o','w',' ','g','o','e','s',' ','M','O','O','\0'};
for(counter = 0; counter < 14; counter++)
printf("%c", pCow[counter]);
the program crashes and pCow refuses to moo for my hedonistic pleasure!
3 Warnings. 0 Errors
line 11 (near initialization for 'pCow') [enabled by default] C/C++ Problem
line 11 excess elements in scalar initializer [enabled by default] C/C++ Problem
line 11 initialization makes pointer from integer without a cast [enabled by default] C/C++ Problem
Lovingly tested in Eclipse CDT.