Hai all,
I just want to ask, after compiling and executing a certain program in
C++, when I try to run the .exe file, it displays the output and close
very fast in a way that I can't read what have been written in the
screen...Why does this happen? and how to fix it?
Thanx alot,
Rashrashetta 9 1824
Rashrashetta wrote: I just want to ask, after compiling and executing a certain program in C++, when I try to run the .exe file, it displays the output and close very fast in a way that I can't read what have been written in the screen...Why does this happen? and how to fix it?
Put some input at the very end of the 'main' function, which would
stop the program so you can look at the output. I usually do something
like
...
std::cout << "Press Enter..." << std::flush;
std::string dummy;
std::getline(std::cin, dummy);
}
V
There is probably an error in your program and an exit call. If you do
not have a program with a debugger than can move line by line, then I
would insert some
cout<<"test : did I get here"<<endl;
system("PAUSE");
in key spots throughout your code to find out which line is causing the
program to quit.
Victor Bazarov wrote: Rashrashetta wrote: I just want to ask, after compiling and executing a certain program in C++, when I try to run the .exe file, it displays the output and close very fast in a way that I can't read what have been written in the screen...Why does this happen? and how to fix it?
Put some input at the very end of the 'main' function, which would stop the program so you can look at the output. I usually do something like
... std::cout << "Press Enter..." << std::flush; std::string dummy; std::getline(std::cin, dummy); }
V
Or start a "Command Prompt" and run the program from there perhaps?
Larry
Rashrashetta wrote: Hai all,
I just want to ask, after compiling and executing a certain program in C++, when I try to run the .exe file, it displays the output and close very fast in a way that I can't read what have been written in the screen...Why does this happen? and how to fix it?
Include a sleep() statement before the output is destroyed.
#include <cstdlib>
int main(int argc, char *argv[]) {
...
std::sleep(5); // Sleep for 5 seconds
return 0;
} Thanx alot, Rashrashetta
Ron Wills wrote: Rashrashetta wrote: I just want to ask, after compiling and executing a certain program in C++, when I try to run the .exe file, it displays the output and close very fast in a way that I can't read what have been written in the screen...Why does this happen? and how to fix it?
Include a sleep() statement before the output is destroyed.
#include <cstdlib>
int main(int argc, char *argv[]) { ...
std::sleep(5); // Sleep for 5 seconds return 0; }
There is no C++ standard function 'sleep' (perhaps you're getting
the POSIX function by that name, if that code works for you).
At 21 Jun 2005 17:15:21 -0700,
Old Wolf wrote: Ron Wills wrote: Rashrashetta wrote: I just want to ask, after compiling and executing a certain program in C++, when I try to run the .exe file, it displays the output and close very fast in a way that I can't read what have been written in the screen...Why does this happen? and how to fix it?
Include a sleep() statement before the output is destroyed.
#include <cstdlib>
int main(int argc, char *argv[]) { ...
std::sleep(5); // Sleep for 5 seconds return 0; }
There is no C++ standard function 'sleep' (perhaps you're getting the POSIX function by that name, if that code works for you).
Opps, looks like your right :P. Just goes to show, never make
assumptions ;). Should be using stdlib.h.
I should propose to put the following lines at the end of main():
std::cout<<"Press a key to end program"<<std::endl;
char dummy;
std::cin.get(dummy);
This will wait for a key press (any key press!) and then exit, and it
is completely portable. Only in case you redirect standar input, you
must take some caution.
Sorry, it won´t work with any key, it still needs the return key to
work.
May I say we are working with the A/C broken (whole day at 30ºC) as an
excuse?
Nice day, not too hot, to all! ra*********@hotmail.com (Rashrashetta) wrote: Hai all,
I just want to ask, after compiling and executing a certain program in C++, when I try to run the .exe file, it displays the output and close very fast in a way that I can't read what have been written in the screen...Why does this happen? and how to fix it?
I'd guess that you're using a Windows OS and you're running the
program by using Start|Run. Instead, open a command console ("DOS
Box"). That should be in your Start menu someplace, try Start|All
Programs|Accessories|Command Prompt. That window will stay open when
your program closes. Unless your program is doing something to clear
the screen before closing, you should be able to see the output.
--
Tim Slattery Sl********@bls.gov This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fabio Pliger |
last post by:
Hi,
is it possibile, in python, to check for an already running instance of an
application?
My problem is that, if my program i running and the user relaunch it, i
don't want to open a new...
|
by: Pierre-Yves |
last post by:
Hello,
I would like to prevent my perl program to be executed several times
simultaneously (if the program is already running, I would like to display a
message like "another instance of this...
|
by: Andrew Chalk |
last post by:
I have just moved a project to my laptop and get the message "Visual Studio
..NET has detected that the specified Web server is not running ASP.NET v1.1.
You will be unable to run ASP.NET Web...
|
by: jliusolar |
last post by:
Hi
I am trying to figure out why an application get this error when I am trying to open the application's asmx file from localhost. I don't have indexing service running(it set as manual and not...
|
by: Alphonse Giambrone |
last post by:
I have a small asp.net web app running on a shared host.
It uses a Jet (Access) database. I included a routine to compact the
database when the application_event fires if it has not been compacted...
|
by: WATYF |
last post by:
This is my problem... I have some code that starts a Process and
returns it to a variable... (prcBat)
At any time while that process is running... I want to be able to Kill
it by pressing a...
|
by: mabond |
last post by:
Hi
recently read a posting and reply about Excel processs still running after
the Appliction.Quit was called. Thought I might be able to use the same...
|
by: Michael Malinowski |
last post by:
Is there a way to read the directory that the currently running python file
is located in?
Cheers
Mike.
|
by: geert |
last post by:
Hi all,
I have a mac mini running maocosx 10.5 leopard I want to deploy a
django project on. My backend is MySQL, and I have it running as a 64-
bit app. Of course, apache2 is also running as...
|
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= |
last post by:
On reflection, you could possibly make the app a self extracting zip file
which extracts the EXE and a settings file and then starts the app, then when
you app closes, it can repack the settings...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |