Solved

keeping the info up with a function

Posted on 2000-04-13
3
183 Views
Last Modified: 2010-04-02
I'm have a little problem keeping my output to stay up when it calculates the answer.  It doesn't ask you to hit a key to exit or nothing.  It just shuts off.  It works fine when I execute in visual c++ but when I send the program out with it's own exe it doesn't.  Can't I create a function that will cut it off in 5 seconds?  Or atleast ask the user to hit a key to continue?
0
Comment
Question by:nationnon
  • 2
3 Comments
 
LVL 2

Expert Comment

by:AndrewRodionov
ID: 2711621
Hi nationnon,

Is your application a Win32 console? If so then you can use

#include <iostream.h>
#include <conio.h>
....
char c;

cout.flush();
cout << "Press any key to continue...";
c = getch();    // waits here
....

to wait until user's response.

Andrew.
0
 
LVL 2

Accepted Solution

by:
AndrewRodionov earned 40 total points
ID: 2711638
To sleep your Win32 program you should use

#include <iostream.h>
#include <windows.h>
....
cout.flush();
cout << "Waiting 5 seconds...";
Sleep( 5000 ); // does nothing here
....

Andrew.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2714558
if it is console mode, then run it from a command prompt window.

Alterntaively, make it into a simple dialog (or SDI app with edit view) and have it write to a multi-line edit box that the user can scroll through to view the results and then close when they've seen enough.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now