A changed terminator reveals stored characters

Draw all eight char elements after initialization, give the exact output, and explain how one assignment changes strlen from its original value. Distinguish sizeof text from strlen(text), and explain why both calls to %s are safe here. What does strcmp guarantee when strings are equal, and why should portable code test its sign rather than assume unequal results are exactly -1 or 1?

#include <stdio.h>
#include <string.h>
int main(void) {
    char text[8] = {'c', 'a', 't', '\0', 'x', '\0'};
    printf("before=%s length=%zu capacity=%zu\n", text, strlen(text), sizeof text);
    text[3] = 's';
    printf("after=%s length=%zu\n", text, strlen(text));
    int relation = strcmp(text, "catsx");
    printf("equal=%d\n", relation == 0);
    return 0;
}

