Write a c program to concatenate two strings using pointers

Write a c program to concatenate two strings using pointers. String concatenation is the operation of joining character strings end-to-end in formal language theory and computer programming. This will concatenate the pointer values in c.

#include <stdio.h>
int main()
{
char firstelement[100], secondelement[100];
printf("\nEnter the first string: ");
gets(firstelement); 
printf("\nEnter the second string to be concatenated");
gets(secondelement); 
char *a = firstelement;
char *b = secondelement;
while(*a) 
{
a++; 
}
while(*b) 
{
*a = *b;
b++;
a++;
}
*a = '\0'; 
printf("\n\n\nThe string after concatenation is: %s ", firstelement);
return 0;
}

 

Output:

Enter the first string: inlarn

Enter the second string to be concatenateddotcom

The string after concatenation is: inlarndotcom