In C, we can copy a string to another string using the `strcpy()` function. Here's an example:
```
#include <stdio.h>
#include <string.h>
int main() {
char str1[100] = "Hello, world!";
char str2[100];
strcpy(str2, str1);
printf("Original string: %s\n", str1);
printf("Copied string: %s\n", str2);
return 0;
}
```
In this program, we first declare two character arrays `str1` and `str2`. We initialize `str1` with the string "Hello, world!". We then use the `strcpy()` function to copy `str1` to `str2`. Finally, we print both the original string and the copied string using `printf()`.
Note that the `strcpy()` function copies the contents of the source string to the destination string, including the null character (`\0`) at the end. Also, make sure that the destination string has enough space to accommodate the source string, including the null character.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc