C strcpy(): Complete String Copy Guide
In C language, the strcpy() function can be used to copy a string into another string. This function is defined in the string.h header file with the following prototype:
char *strcpy(char *dest, const char *src);
In this case, dest refers to the target string, and src refers to the source string. Here is a simple example:
#include <stdio.h>
#include <string.h>
int main() {
char src[] = "Hello, World!";
char dest[100];
strcpy(dest, src);
printf("Source string: %s\n", src);
printf("Destination string: %s\n", dest);
return 0;
}
Running the code above will result in the following output:
Source string: Hello, World!
Destination string: Hello, World!