Example 1
#include <stdio.h>
int main(void) {
char word[6] = { 'H', 'e', 'l', 'l', 'o', '\0' };
printf("%s\n", word);
word[0] = 'J';
printf("%s\n", word);
return 0;
} How It Works
- The brace list builds a string manually, including
\0. printf("%s")prints until the terminator.- Assigning
word[0] = 'J'mutates the first character.
