Discussion:
[Dev-C++] RE: Dev C++ Question Vol. 1 #612 - cin.get()
patche
2002-02-12 19:42:24 UTC
Permalink
I myself am a brand new DevCPP fan and am, like you, new to programming CPP. I am not sure where I got this but my list of resources has grown exponentially since the first of the year.

To "pause" a program so that I can see that it works I was told to add one cin.get() and if that didn't work to add cin.get() twice, like this:

#include <iostream.h>
int main()
{
cout<<"The Compiler Works";
cin.get();
cin.get();
return 0;
}

By the way I corrected your example, you had left the ";" out. Nitpicking aside I think the reason why it does that has something to do with the compiler reading a newline command into either [ENTER] key or "\n" and replacing them with "\0" the null symbol. Anyone, care to comment?

patche
Ioannis Vranos
2002-02-12 22:13:01 UTC
Permalink
No it has to do that it reads the number and stores it in the variable
aand the '\n' remains in the stream. This is not a bad thing but a good
one because no information is lost and you have 100% low level control
of the stream.




Ioannis

* Ioannis Vranos
* Programming pages: <http://www.noicys.d2g.com/>
http://www.noicys.d2g.com
* Alternative URL: <http://run.to/noicys> http://run.to/noicys

-----Original Message-----
From: dev-cpp-users-***@lists.sourceforge.net
[mailto:dev-cpp-users-***@lists.sourceforge.net] On Behalf Of patche
Sent: Tuesday, February 12, 2002 6:48 PM
To: dev-cpp-***@lists.sourceforge.net
Subject: [Dev-C++] RE: Dev C++ Question Vol. 1 #612 - cin.get()


Nitpicking aside I think the reason why it does that has something to
do with the compiler reading a newline command into either [ENTER] key
or "\n" and replacing them with "\0" the null symbol. Anyone, care to
comment?

patche

Loading...