#include <stdio.h>
#include <string.h>
int main()
{
char str1[30] = "First";
char str2[6] = "Second";
strcat(str1,str2);
printf("%s",str1);
return 0;
}
Output is "FirstSecondFirst"
when I change str2
size 6 to 7, it functions properly.
I know that it continues to read without stopping if there is no null char, but I don’t understand why the word ‘First’ is repeated.
You need to sign in to view this answers