CS 102 Lab #5

This lab has three parts.

Part 1

Re-write the function identify from last week's lab, to provide the following interface:
int identify(/* in */ const char[] instring)
The function must return an integer value from 0-4, as specified below:
If the string isreturn
John, Paul, George, Ringo1
Phil, Peter, Tony, Mike2
Greg, Carl, Keith3
Nick, Rick, Roger, David4
anything else0

Copy the file lab5-main.C into your directory and compile it with your implementation of identify. Note that the program prompts the user for a string, and then an integer guess, and outputs "Right" if the guess was the type of the string (as returned by your identify function). If the user enters a blank line for the string, the program exits. Run the program and make sure it works with your function.

Part 2

Look again at lab5-main.C, and this time note the method used for getting the integer "guess" value. The getline function is used to read in the integer as a string, then the atoi function is used to convert that string into an integer, which is compared with the return value of your identify function.

Rewrite this main to use the default input operator (>>) to input the value of the guess. Simply replace the lines:

    cin.getline(input2,SIZE);
    guess = atoi(input2);
With the line:
    cin >> guess;
Compile your program, run it, and note that it doesn't work.

Part 3

Now get the program to work using the default input operator to input the guess, and leaving the getline function for input of the string.