This function concatenates the source string at the end of the target string.
syntax:
strcat("target_string","source_string");
example:
source="book"
target="face"
strcat(target,source);
[Here, source string(i.e. book) is add at the end of target string(i.e. face). Hence now value of target string(i.e. face) is "facebook".
illustrate strcat() in C program:
/*c program for strcat() function illustrate*/
#include<stdio.h>
int main()
{
char source[40],target[40];
printf("Enter source string : ");
gets(source);
printf("Enter target string : ");
gets(target);
strcat(target,source);
printf("\nTarget:%s \nSource:%s",target,source);
getch();
return 0;
}
The output of above program would be:
Related program:
syntax:
strcat("target_string","source_string");
example:
source="book"
target="face"
strcat(target,source);
[Here, source string(i.e. book) is add at the end of target string(i.e. face). Hence now value of target string(i.e. face) is "facebook".
illustrate strcat() in C program:
/*c program for strcat() function illustrate*/
#include<stdio.h>
int main()
{
char source[40],target[40];
printf("Enter source string : ");
gets(source);
printf("Enter target string : ");
gets(target);
strcat(target,source);
printf("\nTarget:%s \nSource:%s",target,source);
getch();
return 0;
}
The output of above program would be:
Figure: Screen shot for illustrate strcat() function C program |
Related program:
No comments:
Post a Comment