C examples for String:String Function
Use strcpy() to copy string
#include <stdlib.h> #include <stdio.h> #include <string.h> char source[] = "The source string."; int main( void ) { char dest1[80]; char *dest2, *dest3; printf("\nsource: %s", source ); strcpy(dest1, source);//ww w . ja v a 2s.com printf("\ndest1: %s", dest1); dest2 = (char *)malloc(strlen(source) +1); strcpy(dest2, source); printf("\ndest2: %s\n", dest2); return 0; }