Menu: Difference between revisions

52 bytes added ,  14 years ago
m
neaten up heading material
m (→‎{{header|C++}}: formatting)
m (neaten up heading material)
Line 4:
* Print a textual menu formatted as an index value followed by its corresponding string for each item in the list.
* Prompt the user to enter a number.
* returnReturn the string corresponding to the index number.
 
The function should reject input that is not an integer or is an out of range integer index by recreating the whole menu before asking again for a number. The function should return an empty string if called with an empty list.
 
For test purposes use the four phrases: '“<tt>fee fie'</tt>”, '“<tt>huff and puff'</tt>”, '“<tt>mirror mirror'</tt>” and '“<tt>tick tock'</tt>” in a list.
 
Note: This task is fashioned after the action of the [http://www.softpanorama.org/Scripting/Shellorama/Control_structures/select_statements.shtml Bash select statement].
Anonymous user