This lab has three parts.
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 is | return |
| John, Paul, George, Ringo | 1 |
| Phil, Peter, Tony, Mike | 2 |
| Greg, Carl, Keith | 3 |
| Nick, Rick, Roger, David | 4 |
| anything else | 0 |
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.
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.
getline function for input of
the string.