C Program to concatenate two strings into a third string without using built in functions
Program
#include<stdio.h>
void main()
{
char str_one[20], str_two[20];
char dest_str[40];
int i, j;
printf("Enter string one:\t");
scanf(" %s", str_one);
printf("Enter string two:\t");
scanf(" %s", str_two);
i = 0;
while(str_one[i] != '\0')
{
dest_str[i] = str_one[i];
i++;
}
j = 0;
while(str_two[j] != '\0')
{
dest_str[i] = str_two[j];
i++;
j++;
}
dest_str[i] = '\0';
printf("Concatenated string is: %s\n", dest_str);
}
Output
Enter string one: United
Enter string two: States
Concatenated string is: UnitedStates