How to Merge Strings in C Language
In the C language, merging two strings can be achieved by using the strcat() function, which appends one string to the end of another string.
The example code is as follows:
#include <stdio.h>
#include <string.h>
int main() {
char str1[50] = "Hello, ";
char str2[50] = "world!";
strcat(str1, str2);
printf("Merged string: %s\n", str1);
return 0;
}
In the example above, str1 and str2 are the two strings to be merged. The strcat() function appends str2 to the end of str1, resulting in the merged string “Hello, world!”.