#include <string.h> #include <stdio.h> int main() { char str[12]="hello world"; char copy[15]; strcpy(copy,str); printf("Copied String : %s",copy); return 0; }Source:www.lautturi.com
Note that the length of the array "copy" must be greater than or equal to the string length, otherwise data will be lost and garbled code will be displayed when printing.