How can i make this command? "Press any key to continue"
I have a program, and i have for loop, i need it still working but all loop its finish it, i want the program give the user message "Press any key to continue".
and when the user press any key, the loop will work another loop.
I suggest you put the code in a separate function and call the function in your while loop.
You may also want to check out the FlushConsoleInputBuffer() to get rid of the key pressed.
just check it out this code... if u r having the access of <conio.h>
#include<conio.h>
main()
{
.........
while( ! kbhit())
{
printf(" key not yet pressed");
}
printf("key pressed");
...........
}
My DevC++ automatically puts system("PUASE"); into the file.. and I've already seen that it works on my platform. So I leave it in there, and use it while writing the program, testing and debugging.
It may be slow, but during these stages, my program still has debugging information anyway, so I know it's not running tip top shape.
But, by the time I'm done with the programming (usually even before I put in final steps), I'll have bypassed and even removed it, having put in something of my own. (usualy I don't even remove it. I just never let the program reach it.)
Usually, I put in a while (true) loop, and return out of it to exit the program only when the user asks for the program to quit. But then, most programs i've ran havn't been for single use only, and usually requires repeating the main function until the user is done for the day.
There are apps, I am sure that are meant to be run once.. usually with some sort of argument to a file that it should operate on, and once it's done, it needs not operate on that file anymore. When you create a program that does something like this, and you need to keep the window open so the user can view some sort of status or results in the console, then Duoas's code is probably best.