172. C Program to Concatenate Two Strings Using Pointers.
How does this program work?
- This Program is used to concantenate two strings using pointers.
Here is the code
#include <stdio.h>
int main()
{
char str1[100], str2[100];
char * s1 = str1;
char * s2 = str2;
// Storing two strings
printf("Enter Your FirstName: \n");
gets(str1);//Input1: Skill
printf("Enter Your LastName : \n");
gets(str2);//Input:2 Pundit
// Moving till the end of str1
while(*(++s1));
// Coping str2 to str1
while(*(s1++) = *(s2++));
printf("Concatenated string: %s\n", str1);
//Output: SkillPundit
return 0;
}