>Shouldn't my name be truncated after the 4th character?
C isn't that user-friendly, you get exactly what you ask for, even if it wasn't what you wanted. In your case, run this to see where those extra characters are stored:
Code:
#include <stdio.h>
int main ( void )
{
char left[256] = {0};
char name[4];
char right[256] = {0};
printf ( "Enter your name: " );
fflush ( stdout );
scanf ( "%s", name );
printf ( "left: |%s|\n", left );
printf ( "name: |%s|\n", name );
printf ( "right: |%s|\n", right );
return 0;
}
Now try to think of how many ways that could break your program.