#pragma warning(disable:4996) #include <stdio.h> #include <iostream> char copy_str(char *dest, char *src); struct Books { char name[30]; char auth[30]; char publ[30]; int isborrowed; }; int main() { struct Books Harry_Potter; copy_str(Harry_Potter.name, "Harry Potter"); copy_str(Harry_Potter.auth, "J.K Rolling"); copy_str(Harry_Potter.publ, "Scholastic"); Harry_Potter.isborrowed = 0; printf("Book name: %s\n", Harry_Potter.name); printf("Auth name: %s\n", Harry_Potter.auth); printf("Publ name: %s\n", Harry_Potter.publ); system("pause"); return 0; } char copy_str(char *dest, char *src) { while (*src) { *dest = *src; src++; dest++; } *dest = '\0'; return 1; } |
copy_str
출처: http://itguru.tistory.com/55