Friday 20 January 2012

string concatenation without strcat()


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
char str[20],str1[40];
cout<<"Enter source string"<<endl;
gets(str);
cout<<"Enter target string"<<endl;
gets(str1);
int l=0;
for(int i=0;str1[i]!='\0';i++)
{
l++;
}
int j;
  for(i=0,j=l;str[i]!='\0';i++,j++)
  {
  str1[j]=str[i];
  }
  str1[j]='\0';
  cout<<"The concatenated string is "<<str1;
  getch();
    }

3 comments:

  1. thanx sir,due this i have scored highest marks in c++ in my tuition..........thank you sir, sir please also upload some pointer related program....

    ReplyDelete
  2. dear dheeraj wait i will do it soon

    ReplyDelete
  3. Understanding how variables work in a programming language is practically the basis for learning any programming language. It is good that ready-made solutions like on this site are also available and can be used without any obstacles.

    ReplyDelete