/* ptrArith_5.c We move the copy loop into a function and see that no code needs to be changed except the use of parameter names in the while loop. We no longer need our extra vars char *word_ptr and *name_ptr in main. */ #include #include #include #define WORD_LENGTH 30 void myStrcpy(char *dest, char *src); int main(int argc, char *argv[]) { char word[WORD_LENGTH]; char *name = (char *)malloc(WORD_LENGTH * sizeof(char)); strcpy(name, "Professor"); myStrcpy(word, name); printf("My name is: %s\n", word); return 0; } void myStrcpy(char *dest, char *src) { while (*dest++ = *src++); }