C program to copy one string to another string using while empty Loop and pointers.












C program to copy one string to another string using while empty Loop and pointers.




C program to copy one string to another string using while empty Loop and pointers.



#include <stdio.h> #define MAX 200 int main() { char text1[MAX], text2[MAX]; char * str1 = text1; char * str2 = text2; printf("\n Enter any string: "); gets(text1); while(*(str2++) = *(str1++)); printf("\n First string = %s\n", text1); printf("\n copy string or second string = %s\n", text2); return 0; }


Output:
Enter any string: copy string First string = copy string copy string or second string = copy string




Exercise: 1
C program to copy one string to another string.