Techy Blitz

The science of today is the technology of tomorrow.

Breaking

Thursday, 11 January 2018

C program to join two strings without using strcat

C program to join two strings without using the string library function "strcat" :



Here's the code :-

// Program to concate/join two strings
#include<stdio.h>
#include<string.h>
main()
{
int i,j,n=0;
char str[100],str2[100],str3[100];
printf("Enter string 1:\n");
gets(str);
printf("Enter string 2:\n");
gets(str2);
for(i=0;str[i]!='\0';i++)
{
str3[i]=str[i];
n=n+1;
}
for(i=0,j=n;str2[i]!='\0';i++,j++)
{
str3[j]=str2[i];
}
str3[j]='\0';
printf("The concanted sring is: \n");
puts(str3);
}