Home Articles C program to copy one string to another string.

C program to copy one string to another string.

SHARE

Write a program in C to copy one string to another string.

#include <stdio.h>

#include <string.h>

int main()

{

char source[1000], destination[1000];

printf(“Input a string\n”);

fgets(source, sizeof source, stdin);

strcpy(destination, source);

printf(“Source string: %s\n”, source);

printf(“Destination string: %s\n”, destination);

return 0;

}

Output:

Enter a string:

Welcome to Ekvij.com

Source string: Welcome to Ekvij.com

Destination string: Welcome to Ekvij.com

Back to Programs list.