String concatenation in C,C program to concatenate two string.
In this tutorial we will learn how to write a c program that concatenate two strings.
We will enter two string like first string is - Hello and second string is - Friends,
then the output is - Hello Friends
In this tutorial we will learn how to write a c program that concatenate two strings.
We will enter two string like first string is - Hello and second string is - Friends,
then the output is - Hello Friends
C program code
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,j=0,len;
char str1[100],str2[100];
clrscr();
printf("\n ENTER THE FIRST STRING:\n ");
gets(str1);
printf("\n ENTER THE SECOND STRING:\n ");
gets(str2);
for(i=0;str1[i]!='\0';i++);
str1[i]=' ';
i++;
for(j=0;str2[j]!='\0';j++,i++)
{
str1[i]=str2[j];
}
str1[i]='\0';
printf("\n STRING IS:\n ");
printf("%s\n",str1);
getch();
}
OUTPUT:
Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com
Created by-- HARSH CHAUHAN
No comments:
Post a Comment