cin<<x doesn't show up

Hello I am new to c++ and I am learning online tutorial, I have very simple code I want to show the result in the console.. I used online ideone.com it will gave me result(random number) but how can I want to show the result as output on eclips


#include <iostream>
using namespace std;

int main(void) {
int number;
cin >> number;
cout << "You typed the number " << number <<endl;
cin.get();
return 0;
}
Last edited on
Missing a bracket?

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
using namespace std;

int main(void) {
    int number;
    cin >> number;
    cout << "You typed the number " << number << endl;// this should show me //the number but it didn't.
    cin.get ();
    return 0;

}
Still doesn't show me the results, which should be " You typed the number ....some number...."
Hi,

You didn't cout a prompt, so the program is stopped waiting for input. It works in cpp.sh (the gear icon top right of the code)

Btw, there is no need for the void on line 4, empty parentheses means exactly the same. This has been the case with C++ for a long time.
Last edited on
> cin.get ();
Douas wrote:
your IDE is too stupid to know that a console application run from the IDE should have an automatic pause at the end.
After you inputted the number you pressed <Return>, that's what cin.get() captures, and so, your program terminates.

I would recommend to open a terminal and execute your program there.


Or it may be this http://wiki.eclipse.org/CDT/User/FAQ#Eclipse_console_does_not_show_output_on_Windows
Topic archived. No new replies allowed.