Example 1
#include <stdio.h>
#include <string.h>
int main(void) {
char city[] = "Paris";
char buffer[16] = "Paris";
printf("city: %s (sizeof %zu)\n", city, sizeof city);
strcpy(buffer, "Lyon");
printf("buffer: %s\n", buffer);
return 0;
} How It Works
city[]sizes itself to the literal including\0(6 bytes).bufferhas spare capacity for longer text.strcpycopies"Lyon"including the terminator intobuffer.
