When I run the program, the second printf() prints string2 with whatever was scanned into string1 attached to the end.
e.g. 123 was scanned into string1 then it prints: Is before "12ab123".
as opposed to 12ab.
Why not just "12ab"?
char string1[MAX_STR_LEN];
char string2[4]={'1','2','a','b'};
char five='5';
char abc[3]={'a','b','c'};
printf("Enter a string:");
scanf("%s", string1);
printf("Is before \"%s\":",string2);
A string is a null terminated char array in C.
Change
to
(which is the same as
char string2[] = "12ab";)