S
Sortie
char a[5] = "abcde";
What happens here? Is the "abcde" treated as a string or is it
just used to initialize the character array? If it is treated as
a string, wouldn't it need an extra byte to store the null
termination character, which would mean that the compiler should
throw a warning about writing beyond the allocated memory?
I checked it and didn't get a warning, I also checked
char a[5] = "abcde";
if (a[5]=='\0') printf("TRUE"); /*TRUE*/
So it appears that the "abcde" was used as a string.
What happens here? Is the "abcde" treated as a string or is it
just used to initialize the character array? If it is treated as
a string, wouldn't it need an extra byte to store the null
termination character, which would mean that the compiler should
throw a warning about writing beyond the allocated memory?
I checked it and didn't get a warning, I also checked
char a[5] = "abcde";
if (a[5]=='\0') printf("TRUE"); /*TRUE*/
So it appears that the "abcde" was used as a string.