I have done research online and everyone says don't use them but my teacher isn't accepting that. I also tried clrscr().
I just need something that pauses and something that clears the screen please. If you suggest the things I already above ...they don't work. If there is different versions or ways to do it besides a void that would be helpful. Any input would be greatly appreciated. I am using Dev C++ version 5.5.3.
For a homework solution, if your teacher doesn't care, go ahead and use pause and cls. Just be aware that the commands are different for linux, so if it is to work for your teacher on his *nix box too, you'd have to code things like:
if (system( "cls" )) system( "clear" );
if (system( "pause" )) system( "read -n 1 -p \"Press any key to continue . . .\"" );
...that said, however...
Why are you using these things anyway? Console programs are not supposed to do that. Design your program to not need them.
The "keep the console window from closing" problem is an issue on windows, so you can safely do something like:
if (system( "pause" )) system( "read -n 1 -p \"Press any key to continue . . .\"" );
It works perfect!! Thank you so much. I thought this would be the easiest and it was.
The teacher wanted us to do a menu and have the user select 1 for add, 2 for multiply and 3 to exit.
If they select 1 then they put in the first number, then the second number, then the program will output "The sum of (first number) and (second number) is (answer)." You get the idea. She wanted it to pause after you get the answer so you could read it, then clear everything to select your next option (but leave the menu). It works great now! I appreciate it! I had everything working but the cls and pause.