Hi I got an assignment from my instructor with this exact instruction:

"Your main function should call the function
int getUserOption()
to display the option menu to the user. The function should return an int value indicating the option selected by the user, and the main function should use this value to determine which option to process."

Now I understand that part and how I could go about doing it, but then in another quote

"When the user enters the string QUIT, the program should exit"

I tried asking him if this was a typo or mistake and he said "figure it out". I know you can't use or return strings from an int function and that replying with a string would only catch the first letter. Is there some other way to implement that menu and somehow get a string to pop out, or do you think my instructor just copypasted an old assignment and forgot to change some things?

I'm going ahead and making my menu selection based on a number (i.e: Enter 1 to quit the program, Enter 2 to copy a file...) and then converting that number to a string once it's out of the function later on for clarity. I just wanted to know if there was a way to do what he asked other than my way.

3 Years
Discussion Span
Last Post by Moschops

You could have the user enter a string, and if that string is "QUIT" the programme exits, and if that string is a number, convert it into an int and return it, and if the string is something else, reject it and ask the user to enter a new input.

Edited by Moschops

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.