------------------------------------------------------------------------------
MC logo
String Error
[^] Code Examples
------------------------------------------------------------------------------
<<Simple String Formatter sboom1.c C Structs>>
/*
 * Guess what happens when you strcpy to an area where it doesn't fit?
 */
#include <stdio.h>
#include <string.h>

int main()
{
        char s1[25] = "This is the city.";
        char s2[8];
        char s3[12];
        char s4[4];

        /* strcpy copies the second string to the first. */
        strcpy(s2, s1);
        strcpy(s3, s1);
        strcpy(s4, s1);
        printf("%s %s %s %s\n", s1, s2, s3, s4);
}

This one fails because the strcpy targets are too small. Its actual behavior will be system-dependent.
Reading: pp. 58-66
<<Simple String Formatter C Structs>>