I have a couple messages that if the user enters a wrong choice it says invalid choice then it returns a value to main. But the thing is I don't want to screen to disappear so fast. It would be nice if I had it say
Invalid selection returning to main menu. (for 5 seconds)
I was looking at the time functions in the references. Do people ever do things by time? Say there was a function called TIME it would be cool to write something like...
While(TIME < 5)
cout << Invalid sele......
Would be cool. Anyone ever do something like this?
But you would have to use hit enter to make the program continue. I'm aware you can do that although I never have done it . I think you have to hit enter am I right ? Wouldn't it be cool to use the time though?
Also I'm confused on what library I need. I read it was not in standard library. In this example I believe they used windows.h I tried this and sleep was undefined. Also what is .h I know it means header file what is that.
Use #include <windows> Then where you want a pause before continuing, add in Sleep(1000); 1000 gives 1000 ms or 1 second. So, adjust that number to how long of a delay you need. 1500, for 1.5 seconds, etc.
It's a stylistic thing, but it's somewhat of an "unwritten rule" that all C/C++ programmers should follow.
One of the many problems with macros is that they completely disregard all language scoping rules, which makes them much more prone to name conflicts. The only way to avoid mishaps due to name conflicts is to reserve a certain naming convention for macros and don't use it for anything other than macros. It just so happens that most people tend to use all caps for macros, so that became the unofficial standard.
But really... in the end... just do what your teacher says. Another "unwritten rule" to programming (in any language) is to adopt the style of whatever environment you're working in. If you're class's style is to use all caps for constants, then that is what you should do.
It's not guaranteed to work. According to the language standard it shouldn't work.
The C++ standard states very clearly that main must return an int. Many compilers support the ability to use void main, but that's mainly to support old, pre-standard code.
The bottom line is that int main will always work, no matter which version of which compiler you're using. void main on the other hand may work just fine in one compiler but fail in another*. So really there is no benefit at all to using void main.
* this is mostly an academic point, as you'd be hard-pressed to find a compiler which doesn't support void main