This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes C / C++ and the fly likes beginner problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "beginner problem" Watch "beginner problem" New topic

beginner problem

John Call

Joined: Apr 11, 2011
Posts: 20

Hi i am pretty naive to c++,already knew java.
Please tell me what 's wrong with this simple code.
It's not displaying integer entered by me but return back after entering integer and hitting enter.I am using devc++.
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
Hi friend. so the screen disappears and you can't see the result ...

Solution: use cin.get() twice!

Albatross wrote:You had a '\n' left in your cin's buffer when you called cin.get(), which got the new line and then moved on.
Brian Overland
Ranch Hand

Joined: Sep 09, 2011
Posts: 36
Hmmmn... the problem here may be that programs in console mode, when spawned from Windows (or Mac operating system or whatever), tend to immediately go away when they are done running. That is why all the examples in my book use system("PAUSE");

However, the use of cin.get() recommended by the other post should work fine, I think.

Hope this helps... best of luck with your programming,

Brian Overland
I agree. Here's the link:
subject: beginner problem
Similar Threads
How to transport 2 dimension array of integer using byte array.
JVM crash
Exception: STATUS_ACCESS_VIOLATION - pointer referencing
does java support shared memory concept
Don't understand C++ Iterators and Vectors