Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 29th, 2007, 10:10 PM
Authorized User
 
Join Date: Apr 2007
Location: Toronto, ontario, .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default C++ Pause comand line

I'm having a very difficult time with my compiler- Dev-C++ the problem is when I compile something like this


// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

my comand line doesn't even come up for a second. I know there is such thing as system("pause") but I don't no how to run it through the script can somebody show me how to do this with that simple script above? Thx,

Reply With Quote
  #2 (permalink)  
Old April 30th, 2007, 12:41 PM
Friend of Wrox
 
Join Date: Jan 2006
Location: Fort Wayne, Indiana, USA.
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Geo121
Default

Okay this is a very simple problem

Your program is running and you don't want to use system pause

your best bet would be to use cin.get()

However this is really not the best standard to follow

You instead should open your command prompt (cmd) and direct it the location of the .exe file and type the name of the .exe file to run it and once it is finished executing the window will remain open so you can verify that the program is running correctly

~ Geo

~ Don't take life too seriously, you'll never get out alive!
Reply With Quote
  #3 (permalink)  
Old June 1st, 2007, 03:48 AM
Registered User
 
Join Date: May 2007
Location: nanjing, jiangsu, China.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Between the line cout and return you can add a line of "system("pause");"
then you can hold on your comand
Good Luck!!

Reply With Quote
  #4 (permalink)  
Old June 20th, 2007, 09:28 AM
Registered User
 
Join Date: Jun 2007
Location: Oklahoma City, Oklahoma, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to TotcoS Send a message via MSN to TotcoS Send a message via Yahoo to TotcoS
Default

Quote:
quote:Originally posted by ZORCH
 I'm having a very difficult time with my compiler- Dev-C++ the problem is when I compile something like this


// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

my comand line doesn't even come up for a second. I know there is such thing as system("pause") but I don't no how to run it through the script can somebody show me how to do this with that simple script above? Thx,

If all you want is a pause without the "Press any key to continue . . ."
Code:
#include <iostream>
using namespace std;

int main() {
  cout << "Hello, World!";
  system("PAUSE >> NULL");
  return(0);
}
-OR-
Code:
#include <iostream>
using namespace std;

int main() {
  cout << "Hello, World!";
  cin.get();
  return(0);
}
Happy Coding,
Scott Stauffer aka TotcoS of BlackHat-Forums.

I don't need a signature =D
Reply With Quote


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Can I Pause Loop dsmike2008 VB How-To 5 July 18th, 2008 01:01 PM
Pause between macros paul20091968 Access VBA 2 April 6th, 2007 01:40 AM
"Pause" Checking ... tonyrosen Excel VBA 2 November 23rd, 2005 11:02 AM
Getting info from comand line prompt red4vbs VBScript 2 February 17th, 2005 07:41 AM
Add a Pause snowy0 VB.NET 2002/2003 Basics 3 February 1st, 2004 12:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.