Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Automatic pause not working in C++

- - - - -

  • Please log in to reply
6 replies to this topic

#1
DragonPark

DragonPark

    Junior

  • Member
  • Pip
  • 58 posts
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?


How to remove advertisement from MSFN

#2
Crispy

Crispy

    Retired Yiffy Moderator

  • Member
  • PipPipPipPipPipPip
  • 1,305 posts
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 ...
Posted Image

#3
cje

cje

    Newbie

  • Member
  • 31 posts
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
DragonPark

DragonPark

    Junior

  • Member
  • Pip
  • 58 posts
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
XtremeMaC

XtremeMaC

    MSFN SuperB

  • Member
  • PipPipPipPipPipPipPipPipPipPip
  • 5,070 posts
  • OS:Windows 7 x64
  • Country: Country Flag
hmm u go to command prompt and pause doesn't work????
system("pause"); in c++



#6
HeartsOfWar

HeartsOfWar

    Newbie

  • Member
  • 49 posts
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.
Posted Image

#7
XtremeMaC

XtremeMaC

    MSFN SuperB

  • Member
  • PipPipPipPipPipPipPipPipPipPip
  • 5,070 posts
  • OS:Windows 7 x64
  • Country: Country Flag
oh thats right i totally forgot about that

u need to include conio.h for that






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN