strcat() string handling functions - C-Tutorial

Latest

Friday, 7 October 2016

strcat() string handling functions

C - strcat() function

  • ·         strcat( ) function concatenates two given strings. It concatenates source string at the end of destination string. 


Syntax                        :           strcat (targetstring , sourcestring);

Example:
strcat ( str2, str1 ); – str1 is concatenated at the end of str2.
strcat ( str1, str2 ); – str2 is concatenated at the end of str1.

/* PROGRAM TO ADD THE GIVEN TWO STRINGS */


#include<string.h>
main()
{
            char str1[50],str2[50];
            clrscr();
            printf("\nEnter string 1:");
            gets(str1);
            printf("\nEnter string 2:");
            gets(str2);
            printf("\n After adding the string is %s",strcat(str1,str2));
           
}


No comments:

Post a Comment