Solved

keeping the info up with a function

Posted on 2000-04-13
3
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

737 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