str1 and str2 that you specified are string literals that cannot be changed. In linux executables, the contents of the address pointed to by the str1 and str2 tags are stored in the .rodata section of the executable, which cannot be written. In other executable files, the contents are stored in a similar place that cannot be written. To do this, you must use an array or dynamically allocated memory area. Make sure that when you concatenate a string into which you insert another string, there is enough space to store them.
EDIT1:
Or do
char str1[BUFF_SIZ] = "Hello", str2[BUFF_SIZ] = " Man";
or
char *str1, *str2; str1 = malloc (sizeof (char) * BUFF_SIZ); str1 = malloc (sizeof (char) * BUFF_SIZ); strcpy (str1, "Hello"); strcpy (str1, " Man");
source share