473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Command Line Disappears (Win 2000 NT)

Just joined and am learning c++, i have got a compiler, i run the
executable, i get the DOS command prompt showing me my program but once
it gets to the "return 0;" part of the code, basically the end, the
prompt disappears, and i miss out on half of my program. A while back
someone told me of a line of code to put in that fixes this problem,
but i forgot it! Could someone tell me?

thank you!

Jul 11 '06 #1
5 2893
"poolshark1691" wrote:
Just joined and am learning c++, i have got a compiler, i run the
executable, i get the DOS command prompt showing me my program but once
it gets to the "return 0;" part of the code, basically the end, the
prompt disappears, and i miss out on half of my program. A while back
someone told me of a line of code to put in that fixes this problem,
but i forgot it! Could someone tell me?
I had that problem the first time I started programming on a Windows
computer, back in 1996. There's 3 easy ways around it, though:

1. (The best by far): lauch a command-prompt window BEFORE you run
your program, and run the program from within that window, by
typing its name.
2. (For people hoplessly addicted to icons): Right-click the icon
that launches your program, select "Properties", go to the
"Program" tab, and UN-check the little box that says "close on
exit".
3. (The really stupid way:) put this line of code at the bottom of
main(), just above "return 0;":
system("pause");

--
Cheers,
Robbie Hatley
East Tustin, CA, USA
lone wolf intj at pac bell dot net
(put "[usenet]" in subject to bypass spam filter)
http://home.pacbell.net/earnur/
Jul 11 '06 #2

"Robbie Hatley" <bo***********@no.spamwrote in message
news:4P*******************@newssvr21.news.prodigy. com...
"poolshark1691" wrote:
>Just joined and am learning c++, i have got a compiler, i run the
executable, i get the DOS command prompt showing me my program but once
it gets to the "return 0;" part of the code, basically the end, the
prompt disappears, and i miss out on half of my program. A while back
someone told me of a line of code to put in that fixes this problem,
but i forgot it! Could someone tell me?

I had that problem the first time I started programming on a Windows
computer, back in 1996. There's 3 easy ways around it, though:

1. (The best by far): lauch a command-prompt window BEFORE you run
your program, and run the program from within that window, by
typing its name.
2. (For people hoplessly addicted to icons): Right-click the icon
that launches your program, select "Properties", go to the
"Program" tab, and UN-check the little box that says "close on
exit".
3. (The really stupid way:) put this line of code at the bottom of
main(), just above "return 0;":
system("pause");
I think #1 and #2 won't help if you're running from an IDE. And #3 depends
on the OS, right? To do this in my console apps, I use cin to a string. It
requires me to type at least one character and then hit Enter, but it works.

-Howard

Jul 11 '06 #3
"poolshark1691" <po***********@gmail.comwrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Just joined and am learning c++, i have got a compiler, i run the
executable, i get the DOS command prompt showing me my program but once
it gets to the "return 0;" part of the code, basically the end, the
prompt disappears, and i miss out on half of my program. A while back
someone told me of a line of code to put in that fixes this problem,
but i forgot it! Could someone tell me?

thank you!
Instead of running the program with F5 use Ctrl-F5 and the output will stay
until you press a key.

Method 1 (OS specific):
system("pause");

Method 2 (works on any system):
#include <string>
#include <iostream>
std::string wait;
std::cin >wait;
Jul 12 '06 #4
Howard <al*****@hotmail.comwrote:
>
"Robbie Hatley" <bo***********@no.spamwrote in message
news:4P*******************@newssvr21.news.prodigy. com...
>"poolshark1691" wrote:
>>Just joined and am learning c++, i have got a compiler, i run the
executable, i get the DOS command prompt showing me my program but once
it gets to the "return 0;" part of the code, basically the end, the
prompt disappears, and i miss out on half of my program. A while back
someone told me of a line of code to put in that fixes this problem,
but i forgot it! Could someone tell me?

I had that problem the first time I started programming on a Windows
computer, back in 1996. There's 3 easy ways around it, though:

1. (The best by far): lauch a command-prompt window BEFORE you run
your program, and run the program from within that window, by
typing its name.
2. (For people hoplessly addicted to icons): Right-click the icon
that launches your program, select "Properties", go to the
"Program" tab, and UN-check the little box that says "close on
exit".
3. (The really stupid way:) put this line of code at the bottom of
main(), just above "return 0;":
system("pause");

I think #1 and #2 won't help if you're running from an IDE. And #3 depends
on the OS, right? To do this in my console apps, I use cin to a string. It
requires me to type at least one character and then hit Enter, but it works.
Instead of

std::string trash;
std::cin >trash;

I prefer

std::string trash;
std::getline(std::cin, trash);

so that I do not have to type an extra character.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jul 12 '06 #5
Jim Langston <ta*******@rocketmail.comwrote:
Method 2 (works on any system):
#include <string>
#include <iostream>
std::string wait;
std::cin >wait;
As I replied to Howard, I prefer

std::getline(std::cin, wait);

so that I don't have to type an extra character.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jul 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Christian Long | last post by:
Hi I'm trying to pipe data into a python program on Windows 2000, on the command line. Like this: dir | myProgram.py Here's what I tried:
6
by: hugh welford | last post by:
Hi Currently using WIN 98 + PWS for off line web development Will WIN 2000 PRO support PWS? or does it have IIS5 bundled with it, or does it support no web server at all?
0
by: Tom Dacon | last post by:
"Open .Net Command Window Here" context menu for Windows Explorer: The reg file described below adds a new menu item to Windows Explorer's context menu when you right-click over a folder (or the...
2
by: Oleg Medyanik | last post by:
Hi, i wonder if someone can explain the following... Create new Console application... static void Main(string args) { Console.WriteLine(args); } Run it with the following param ...
1
by: Steve | last post by:
My access 2000 project was written on a win 98 machine and has a macro with a condition DateValue(FileDateTime("c:\database\full22.txt"))<Date() This was written in expression builder. On...
5
by: Jarod | last post by:
Hey I have already written a program that has a user interface, but I would like to add some command line interface too. So if the user run it like: program.exe paramater1 The program do...
0
by: Mike Oliver | last post by:
I'm having an issue installing a Windows Service on Win 2K3. After the installation, the service shows up in the Services list through Control Panel, but after the server reboots, it disappears...
1
by: Ennio-Sr | last post by:
Hi all! I'm writing a script that presents the user with a numbered lines menu, each line corresponding to a <case n> which executes a psql command. As the psql-commands are very similar to each...
51
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.