C program to concatenate two strings using while empty loop.












C program to concatenate two strings using while empty loop.




C program to concatenate two strings using while empty loop.



#include <stdio.h> #define MAX 100 int main() { char text1[MAX], text2[MAX]; int i, j; printf("\n Enter first string: "); gets(text1); printf("\n Enter second string: "); gets(text2); i=-1; while(text1[++i]); j = 0; while(text1[i++] = text2[j++]); printf("\n Concatenated 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.