In this C program we will concatenate the source string at the end of the target string using strcat()fuction. The String will be given by the User.color>
strcat() function concatenates the source string which is source_str in this program, at the target string which is target_str in this program. strcat() takes two arguements.
Like :
strcat(target_str,source_str);
Learn about different string functions and their use: Different String Functions
input:
The String.output:
The input string and the concatenated string will be printed on the screen.CODE---->
#include
int main()
#include
{
char source_str[100],target_str[100]="Hello ";
printf("Please, Enter the string: ");
gets(source_str);
strcat(target_str,source_str);
printf("\nSource String is: ");
puts(source_str);
printf("\nTarget String is: ");
puts(target_str);
return 0;
}
Download the C-Program file of this Program.
RESULT :color>
Please, Enter the string: World
Source String is: World
Target String is: Hello World
--------------------------------
Process exited after 4.922 seconds with return value 0
Press any key to continue . . .
Images for better understanding : color>