Write a program to concatenate one string contents to another.


Write a program to concatenate one string contents to another.
Concatentate of string in c++ code.
Write c++ code to concatenate of sting.

 
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
 
int main( )
{
        clrscr( );
 
        char str1[80],str2[80];
        cout<<"Enter first string :";
        gets(str1);
        cout<<"Enter second string :";
        gets(str2);
 
        for(int l=0;str1[l]!='\0';l++);
 
        for(int i=0;str2[i]!='\0';i++)
               str1[l++]=str2[i];
 
        str1[l]='\0';
 
        cout<<"\nThe first string after adding second string content is\n\n"<<str1;
 
        getch();
        return 0;
}
 

No comments:

Post a Comment