Write a program to concatenate two strings.

Showing Answers 1 - 2 of 2 Answers

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
char name[50],fname[15],sname[15],lname[15];
int i,j,k;
clrscr();
printf("First name:");
gets(fname);
printf("Second name:");
gets(sname);
printf("Last name:");
gets(lname);

for(i=0;fname[i]!='';i++)
name[i]=fname[i];
name[i]=' ';

for(j=0;sname[j]!='';j++)
name[i+j+1]=sname[j];
name[i+j+1]=' ';

for(k=0;lname[k]!='';k++)
name[i+j+k+2]=lname[k];
name[i+j+k+2]='';

printf("nn");
printf("Complete name after concatenation:n");
printf("%s",name);


getche();
}

sojitra.Ankit.k

  • Sep 22nd, 2011
 

Code
  1. #include<iostream.h>

  2. #include<conio.h>

  3. #include<string.h>

  4. #include<stdio.h>

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions