CONCATENATE TWO STRINGS WITHOUT USING STRING FUNCTIONS

/*PROGRAM TO CONCATENATE TWO STRINGS WITHOUT USING STRING FUNCTIONS*/

#include<conio.h>

#include<iostream.h>

#include<stdio.h>

class concat

{

char a[20],b[10];

int i,j;

public:

void input();

void output();

};

void concat::input()

{

cout<<“Enter first string: “;

gets(a);

cout<<“Enter second string: “;

gets(b);

}

void concat::output()

{

i=0;

while(a[i]!=’\0′)

{

i++;

}

j=0;

while(b[j]!=’\0′)

{

a[i]=b[j];

i++;

j++;

}

a[i]=’\0′;

cout<<“After concatenation string is: “;

puts(a);

}

void main()

{

concat c1;

clrscr();

c1.input();

c1.output();

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *