"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Thursday, January 7, 2010

Concat 2 strings into One(without strcat() func)


#include<iostream.h>
#include<conio.h>


void main()
{
char s1[20], s2[20], target[40];
cout<<"\n Enter 1st String:";
cin.getline(s1,20);
cout<<"\n Enter 2nd String:";
cin.getline(s2,20);


iny k = 0;


/* First string into the target */
for(int i = 0; s1[i]!='\0';i++,k++)
target[k] = s1[i];


/* Append second string into target */
for(i = 0; s2[i]!='\0';i++,k++)
target[k] = s2[i];




clrscr();
cout<<"\n The Firstly Entered String = "<<  s 1;
cout<<"\n Next  Entered String = "<< s 2;
cout<<"\n\n The Output String = "<< target;


getch();
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.