|
From: Benjamin W. <ben...@ho...> - 2002-02-13 17:44:56
|
<html><div style='background-color:'><DIV>
<P>Ahhh... good 'ole' DOS. :)</P></DIV>
<DIV></DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif" size=2>Benjamin Wheeless</FONT></DIV>
<DIV></DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif" size=2><STRONG>Network Systems - Delta Airlines, Inc.</STRONG></FONT></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2><STRONG>Atlanta, GA - USA 30320</STRONG></FONT></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2><STRONG>==============================</STRONG></FONT></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>----Original Message Follows----
<DIV></DIV>From: gi...@li...
<DIV></DIV>To: dev...@so...
<DIV></DIV>Subject: Re: [Dev-C++] Re: cin.get()
<DIV></DIV>Date: Wed, 13 Feb 2002 15:12:43 +0100
<DIV></DIV>
<DIV></DIV>Hello Aaron,
<DIV></DIV>
<DIV></DIV>since you are developing console applications, my suggestion is: run them
<DIV></DIV>from the console. In fact, when you use the console, there is no need to
<DIV></DIV>add "cin.get" or "system("PAUSE")" or any other special instruction
<DIV></DIV>preventing Windows from closing the window :-)
<DIV></DIV>
<DIV></DIV>For instance, the following code would work as expected:
<DIV></DIV>
<DIV></DIV>#include <IOSTREAM>
<DIV></DIV>int
<DIV></DIV>main()
<DIV></DIV>{
<DIV></DIV>std::cout << "Please enter a number:";
<DIV></DIV>
<DIV></DIV>int n;
<DIV></DIV>std::cin >> n;
<DIV></DIV>
<DIV></DIV>std::cout << "You entered: "<< n << '\n';
<DIV></DIV>}
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>At 13:43 12/02/02 -0500, Aaron wrote:
<DIV></DIV>>Hello...
<DIV></DIV>>
<DIV></DIV>>I have a question about closing a terminal window during a C++
<DIV></DIV>>program
<DIV></DIV>>execution. I am using Dev C++ 4.01 as my compiler. At
<DIV></DIV>>http://www.cprogramming.com/close.html, it says that inserting the
<DIV></DIV>>line
<DIV></DIV>>cin.get() before the return 0 line will keep the terminal window
<DIV></DIV>>open
<DIV></DIV>>until I press enter. This I find is true for the following program:
<DIV></DIV>>
<DIV></DIV>>#include <IOSTREAM.H>
<DIV></DIV>>int main()
<DIV></DIV>>{
<DIV></DIV>> cout<<"The Compiler Works";
<DIV></DIV>> cin.get()
<DIV></DIV>> return 0;
<DIV></DIV>>}
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>However for the following code, I type my number, press enter, and
<DIV></DIV>>the window
<DIV></DIV>>closes immediately. Why doesn't the compiler display "You entered:
<DIV></DIV>>", then my
<DIV></DIV>>number, and then close the terminal window once I push enter (which
<DIV></DIV>>would be
<DIV></DIV>>the second time)?? Am I putting the cin.get() statement in the
<DIV></DIV>>wrong spot??
<DIV></DIV>>Check out the code I'm using.
<DIV></DIV>>
<DIV></DIV>>#include <IOSTREAM.H>
<DIV></DIV>>int main()
<DIV></DIV>>{
<DIV></DIV>> int thisisanumber;
<DIV></DIV>> cout<<"Please enter a number:";
<DIV></DIV>> cin>>thisisanumber;
<DIV></DIV>> cout<<"You entered: "<<THISISANUMBER; DIV <>> cin.get()
<DIV></DIV>> return 0;
<DIV></DIV>>}
<DIV></DIV>>
<DIV></DIV>>I'm stuck, and I'm trying to teach myself C++. Your help is greatly
<DIV></DIV>>appreciated.
<DIV></DIV>>
<DIV></DIV>>Sincerly,
<DIV></DIV>>Aaron
<DIV></DIV>
<DIV></DIV>--
<DIV></DIV>gisan
<DIV></DIV>gi...@li...
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>_______________________________________________
<DIV></DIV>Dev-cpp-users mailing list
<DIV></DIV>Dev...@li...
<DIV></DIV>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_etl_EN.asp'>http://explorer.msn.com</a>.<br></html>
|
|
From: Benjamin W. <ben...@ho...> - 2002-02-13 17:46:54
|
<html><div style='background-color:'><DIV>
<P>Ahhh... good 'ole' DOS. :)</P></DIV>
<DIV></DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif" size=2>Benjamin Wheeless</FONT></DIV>
<DIV></DIV>
<DIV><FONT face="Geneva, Arial, Sans-serif" size=2><STRONG>Network Systems - Delta Airlines, Inc.</STRONG></FONT></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2><STRONG>Atlanta, GA - USA 30320</STRONG></FONT></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2><STRONG>==============================</STRONG></FONT></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>----Original Message Follows----
<DIV></DIV>From: gi...@li...
<DIV></DIV>To: dev...@so...
<DIV></DIV>Subject: Re: [Dev-C++] Re: cin.get()
<DIV></DIV>Date: Wed, 13 Feb 2002 15:12:43 +0100
<DIV></DIV>
<DIV></DIV>Hello Aaron,
<DIV></DIV>
<DIV></DIV>since you are developing console applications, my suggestion is: run them
<DIV></DIV>from the console. In fact, when you use the console, there is no need to
<DIV></DIV>add "cin.get" or "system("PAUSE")" or any other special instruction
<DIV></DIV>preventing Windows from closing the window :-)
<DIV></DIV>
<DIV></DIV>For instance, the following code would work as expected:
<DIV></DIV>
<DIV></DIV>#include <IOSTREAM>
<DIV></DIV>int
<DIV></DIV>main()
<DIV></DIV>{
<DIV></DIV>std::cout << "Please enter a number:";
<DIV></DIV>
<DIV></DIV>int n;
<DIV></DIV>std::cin >> n;
<DIV></DIV>
<DIV></DIV>std::cout << "You entered: "<< n << '\n';
<DIV></DIV>}
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>At 13:43 12/02/02 -0500, Aaron wrote:
<DIV></DIV>>Hello...
<DIV></DIV>>
<DIV></DIV>>I have a question about closing a terminal window during a C++
<DIV></DIV>>program
<DIV></DIV>>execution. I am using Dev C++ 4.01 as my compiler. At
<DIV></DIV>>http://www.cprogramming.com/close.html, it says that inserting the
<DIV></DIV>>line
<DIV></DIV>>cin.get() before the return 0 line will keep the terminal window
<DIV></DIV>>open
<DIV></DIV>>until I press enter. This I find is true for the following program:
<DIV></DIV>>
<DIV></DIV>>#include <IOSTREAM.H>
<DIV></DIV>>int main()
<DIV></DIV>>{
<DIV></DIV>> cout<<"The Compiler Works";
<DIV></DIV>> cin.get()
<DIV></DIV>> return 0;
<DIV></DIV>>}
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>However for the following code, I type my number, press enter, and
<DIV></DIV>>the window
<DIV></DIV>>closes immediately. Why doesn't the compiler display "You entered:
<DIV></DIV>>", then my
<DIV></DIV>>number, and then close the terminal window once I push enter (which
<DIV></DIV>>would be
<DIV></DIV>>the second time)?? Am I putting the cin.get() statement in the
<DIV></DIV>>wrong spot??
<DIV></DIV>>Check out the code I'm using.
<DIV></DIV>>
<DIV></DIV>>#include <IOSTREAM.H>
<DIV></DIV>>int main()
<DIV></DIV>>{
<DIV></DIV>> int thisisanumber;
<DIV></DIV>> cout<<"Please enter a number:";
<DIV></DIV>> cin>>thisisanumber;
<DIV></DIV>> cout<<"You entered: "<<THISISANUMBER; DIV <>> cin.get()
<DIV></DIV>> return 0;
<DIV></DIV>>}
<DIV></DIV>>
<DIV></DIV>>I'm stuck, and I'm trying to teach myself C++. Your help is greatly
<DIV></DIV>>appreciated.
<DIV></DIV>>
<DIV></DIV>>Sincerly,
<DIV></DIV>>Aaron
<DIV></DIV>
<DIV></DIV>--
<DIV></DIV>gisan
<DIV></DIV>gi...@li...
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>_______________________________________________
<DIV></DIV>Dev-cpp-users mailing list
<DIV></DIV>Dev...@li...
<DIV></DIV>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV></div><br clear=all><hr>Chat with friends online, try MSN Messenger: <a href='http://go.msn.com/bql/hmtag1_etl_EN.asp'>Click Here</a><br></html>
|