Solved

keeping the info up with a function

Posted on 2000-04-13
3
185 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ to C# code conversion issue 4 112
C++ question 3 70
Installshield for Embarcadero EX 10.1 Berlin 4 60
find Speed using GPS latitude & longitude 4 42
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

839 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