Sunday, April 28, 2013

strcat()

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:


Output of illustrate strcat() function C program
Figure: Screen shot for illustrate strcat() function C program


Related program:
  1. List of standard library function
  2. strlen()
  3. strcpy()
  4. strncpy()

No comments:

Post a Comment