/* File: copy3.c Use string library copy function This version is still unsafe! */ #include #include #include #include #define MAXLENGTH 12 int main() { char another[MAXLENGTH] = "Hello World" ; char *ptr, str[MAXLENGTH] ; ptr = readline("Enter string: ") ; printf("Length of string = %d\n", strlen(ptr) ) ; strncpy(str, ptr, MAXLENGTH) ; printf("Copy of string here: %s\n", str) ; printf("Another string: %s\n", another) ; free(ptr) ; return 0 ; }