Solved

keeping the info up with a function

Posted on 2000-04-13
3
182 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

  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 …
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

771 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

17 Experts available now in Live!

Get 1:1 Help Now