MSFN Forum: Automatic pause not working in C++ - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Automatic pause not working in C++ "Press any key to Continue..." Rate Topic: -----

#1 User is offline   DragonPark 

  • Junior
  • Pip
  • Group: Members
  • Posts: 58
  • Joined: 30-December 03

Posted 21 February 2004 - 03:38 AM

I am taking a C++ class and am having a problem with running my programs on my machine. When i make a simple program with dos output at school, i will get a nice auto pause at the end of the program. It usually says "Press any key to Continue..." But for some reason i do not get this on my machine. In a matter of fact, I dont get the pause while running any dos apps at all. The program will run, display and exit before I have a chance to see what has been displayed. I know i can put a simple cin to pause the program until the user hits a key, but my teacher would like me to keep that out of the final print out, and i can be quite forgetful at times.

Does anybody know how to get this message displayed without any edits to the program itself?


#2 User is offline   Crispy 

  • Retired Yiffy Moderator
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,305
  • Joined: 14-September 02

Posted 21 February 2004 - 03:52 AM

I don't know if its what you're looking for, but if you open the commando prompt window manually instead of running your app via Windows Explorer it doesn't close after being run ...

#3 User is offline   cje 

  • Newbie
  • Group: Members
  • Posts: 31
  • Joined: 11-October 03

Posted 21 February 2004 - 04:02 AM

The pause after the program runs is a feature of the IDE look for options or compile options and check whether or not it is configured to close the program after compillation.

#4 User is offline   DragonPark 

  • Junior
  • Pip
  • Group: Members
  • Posts: 58
  • Joined: 30-December 03

Posted 21 February 2004 - 06:07 AM

I forgot to mention that i have VC++ .Net 2003. I am creating a basic Win32 Console App. Im not able to find any options for IDE anywhere. Dont know if im just not looking hard enough or if your talking about a different version of Visual Studio all together.

I think that there is a change to make in the OS to add the pause at the end of a program just because i know that ME would pause after typing ipconfig in run, while XP just displays and closes the command window right away.

#5 User is offline   XtremeMaC 

  • MSFN SuperB
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,070
  • Joined: 13-October 03

Posted 22 February 2004 - 03:51 AM

hmm u go to command prompt and pause doesn't work????
system("pause"); in c++

#6 User is offline   HeartsOfWar 

  • Newbie
  • Group: Members
  • Posts: 49
  • Joined: 25-February 04

Posted 25 February 2004 - 08:26 PM

at the end of your code put getch(); or getchar();

getch() is the ANSI standard, but MS changed it to getchar() in VC or VS

This will force the program to wait for a keystroke.

#7 User is offline   XtremeMaC 

  • MSFN SuperB
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,070
  • Joined: 13-October 03

Posted 25 February 2004 - 08:31 PM

oh thats right i totally forgot about that

u need to include conio.h for that

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy