In C language, two strings are concatenated to form a single string.
To merge two strings into one string, you can use the strcat() function.
The prototype of the strcat() function is as follows:
char *strcat(char *dest, const char *src);
In this case, dest represents the destination string and src represents the source string to be added.
Here is an example program demonstrating how to concatenate two strings into one using the strcat() function.
#include <stdio.h>
#include <string.h>
int main() {
char str1[20] = "Hello, ";
char str2[10] = "world!";
strcat(str1, str2);
printf("Concatenated string: %s\n", str1);
return 0;
}
The output result is:
Concatenated string: Hello, world!
In this example, we have concatenated str2 to the end of str1, resulting in a new string.