Lab 12

Please do the QUIZ first!

This week we are going to play with c string. 

You can find a template program below to start with. You are going to write the function CountAndPrint. This function will take a char pointer as parameter, print each word in that string in a line, and return the total number of words in that string.

ATTENTION: You should write your code in the function CountAndPrint, not in the main. (There was a minor bug in the template code, but it does not matter to your CountAndPrint. A change was made to main.)

Don't use strtok.

To repeat, your CountAndPrint does two things:

1. print each word

2. return word count

Sample input: Rats live on no evil star

Sample output:

You entered: Rats live on no evil star

Those words individually are:

Rats

live

on

no

evil

star

There were 6 words

Submission:

Your program should print your (and your partner's) name and netid. Simply replace the stuff at the beginning of main function.

Submit only code file. No binary file or temp file.