/* ptrArith_3.c same as 2 but we condense the syntax slightly by incrementing while dereferencing the pointers. Notice that the ++ operator has precedence over the * operator! Study this carefully! */ #include #include #include #define WORD_LENGTH 30 int main(int argc, char *argv[]) { char word[WORD_LENGTH]; char *name = (char *)malloc(WORD_LENGTH * sizeof(char)); char *word_ptr = word, *name_ptr = name; /* the start of each string */ strcpy(name, "Professor"); /* Copy "Professor" into word with a loop*/ while (*name_ptr) *word_ptr++ = *name_ptr++; *word_ptr = '\0'; /* append null character */ printf("My name is: %s\n", word); return 0; }