Program to illustrates strcat ( ) function


#include <iostream.h>
#include <conio.h>
#include <string.h>          
void main( )
{
    char s1[20 ] = "Hello";
    char s2[ ] = "Sir";
    cout<<"Before strcat (s1,s2) : \n";
    cout<<" \t s1 = [ " <<s1 << "] , length = " <<strlen(s1)<<endl;
    cout<<" \t s2 = [ " <<s2 << "] , length = " <<strlen(s2)<<endl;
    strcat(s1,s2) ;
    cout<<"After strcat (s1,s2) : \n";
    cout<<" \t s1 = [ " <<s1 << "] , length = " <<strlen(s1)<<endl;
    cout<<" \t s2 = [ " <<s2 << "] , length = " <<strlen(s2)<<endl;
    getch( );               
}

No comments:

Post a Comment