(12-03-2009, 02:28 PM)MrD. Wrote: The difference between using std::endl and "\n" to end a line is that std::endl will also flush the buffer to the screen (ie, is the same as doing << "\n" << std::flush();). Useful if you want to make sure the user will always see what you are pushing into the buffer when you end the line.
+
(12-03-2009, 11:01 AM)Xenocide Wrote:Code:while(option<1 || option>4);
while(option!=4)
You see that, those two loops are almost the same.
You could easy put that all in one loop
Code:
while(option > 4) {
switch(option) {
// cases 1 to 4
// case 1:
// do();
// break;
default:
return 1;
}
}
The default part would execute on every number that's not in the range from 1-4, so no need for option < 1 and the second while loop.
So you can use the default to call the selection menu again.