C program to concatenate two strings without using strcat() function

C program to concatenate two strings without using strncat() function

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

void main()
{
char s1[30],s2[30],s3[60];
int i,j;
clrscr();

printf(“Enter first string:”);
gets(s1);
printf(“Enter second string:”);
gets(s2);

for(i=0;s1[i]!=’’;++i)
s3[i]=s1[i];

for(j=0;s2[j]!=’’;++j)
s3[i+j]=s2[j];

s3[i+j]=’’;

printf(“nThe concatenated string is: %s”,s3);
getch();
}

1 thought on “C program to concatenate two strings without using strcat() function”

Leave a Comment

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