pause trouble

Started by
7 comments, last by dchar3 20 years, 10 months ago
how do i get a windows application to pause without it saying "press any key to continue"?
Advertisement
Like this:


  void Pause(void){    char pause;    pause = _getche();}  
Well, _getche() will get a character from the console with echo, i.e. if the user presses, for example, 'h', then 'h' will be printed to the screen. If you want to get a character from the console without echo, use _getch() (the no 'e' at the end). Incidently, these functions are defined in conio.h.

#include <iostream>
#include <conio.h>

int main()
{
...

std::cout << "Press any key to exit, Sir ...\n";
_getch();

return 0;
}


[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on May 29, 2003 7:00:23 AM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
quote:Original post by dchar3
how do i get a windows application to pause without it saying "press any key to continue"?


Do you mean win32 application that you need to pause automaticly?


use the function

sleep( MS ); where MS is the time to make the application sleep in ms.
----------------------------------------------Petter Nordlander"There are only 10 kinds of people in the world. They who understand binary and those who do not"
Judging from his previous posts and the fact that he mentioned "press any key to continue", I should think he meant Win32 Console Application. If this is the case, the code I suggested in my previous post should work.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
i tried the _getch() but it said "implicit declaration of function ''int_getch(...)''"
You need to include the standard C input library I believe...
#include<cstdio>using namespace std;


[edited by - YoshiN on May 30, 2003 10:14:27 PM]
-YoshiXGXCX ''99
Umm, what''s the difference of _getch() and getch() ?
----------------------------------------------------------------------------------------------------------------------"Ask not what humanity can do for you, ask what you can do for humanity." - By: Richard D. Colbert Jr.
quote:Original post by YoshiN
You need to include the standard C input library I believe...

No, getch()/_getch() requires conio.h.

quote:Original post by Android_s
Umm, what's the difference of _getch() and getch() ?

getch()/_getch() is not part of the ANSI standard, and so it might or might not be supported on every compiler. I believe _getch() does pretty much exactly the same thing as getch(), yet it is just Microsoft's conio.h support. I found, though, that I could use both getch() and _getch() with my Microsoft compiler.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on May 31, 2003 7:42:33 AM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]

This topic is closed to new replies.

Advertisement