C program to concatenate two strings using while empty loop and pointers












C program to concatenate two strings using while empty loop and pointers.




C program to concatenate two strings using while empty loop and pointers.



#include <stdio.h> #define MAX 100 int main() { char text1[MAX], text2[MAX]; char * s1 = text1; char * s2 = text2; /* Input two strings from user */ printf("\n Enter first string: "); gets(text1); printf("\n Enter second string: "); gets(text2); while(*(++s1)); while(*(s1++) = *(s2++)); printf("\n Concatenated of two strings = %s", text1); return 0; }


Output:
Enter first string: In Enter second string: dia Concatenated strings = India




Exercise: 1
Write a C program to concatenate two strings.