Since what is present in memory beyond "United" is not known and we are attching "Front" at the end of "United", thereby overwriting something, which is an unsafe thing to do.
see the declarations You have specified here. char *s1="hello"; char *s2="world"; Now U self check whether you get the same output hello for gets(s1); (or else) printf("%c",s1);
Definitely No.
Because *s1 is different from s1.
we know &(*s1)=s1.Here You are calling the address of s1 but not the actual *s1. So try to change it as
char *s1="hello"; char *s2="world"; char *s3=strcat(s1, s2); here, we are not allocating the memory to the s3. so givs "Segmentation Fault". And that to we cant not assign the strcat val to s3, as strcat returns a pointer to the resulting dest string, which is s1 here.
This code will not work. Because the strings "hello" and "world" are stored in data section and their starting address will be assigned to pointers. Since strcat appends the second string at the end of the first string and the address after hello is only readable or may not be in our process address space it gives Segmentation Fault when executed.
Changing this code snippet to the following will work: