Mega Code Archive

 
Categories / C / Code Snippets
 

Concatenates a copy of str2 to str1 and terminates str1 with a null

//Declaration: char *strcat(char *str1, const char *str2); //Return: returns *str1. #include <stdio.h> #include <string.h> int main(void) { char str1[80], str2[80]; printf("str1:"); gets(str1); printf("str2:"); gets(str2); strcat(str2, str1); printf(str2); return 0; } /* str1:s str2:2 2s*/