/* DEMO4 same as 3 but we condense the syntax to it's minimal form via a while loop and eliminate the explicit NULL assignment after the loop */ #include #include #include int main() { char word[10]; char *name = malloc( 10 * sizeof(char) ); char *word_ptr=word, *name_ptr=name; /* the start of each string */ strcpy( name, "timothy" ); while ( (*word_ptr++ = *name_ptr++) ); /* Question: Why don't we need to copy a null onto the end after the loop finishes? Answer: Because the asignment must complete from right to left and then the value on left is evaluted to be true or false by the if statement */ printf("my name is: %s\n", word ); free( name ); return 0; }