what is the difference between the output of online ide and output of eclipse and visual studio ?

I am new on c++, Please see this screen shot for what I get from ideone.com

http://s33.postimg.org/58bxsow8v/ideone.png

you can see the output is a random number result from cin >> number;
, but when I use visual studio or eclipse doesn't show me the same output which is the random number number=-1219862963

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

int main(void) {
    int number;
    cin >> number;//this is generate a random number but I am not sure if I am right about this.
    cout << "You typed the number " << number << endl;// this should show me the number but it didn't.
    cin.get ();
    return 0;

}
Last edited on
cin >> number;
//this is generate a random number but I am not sure if I am right about this.

You're wrong about this.

It fetches a value from the input. typically, from the keyboard.

When using ideone, because you don't have access to the keyboard (because it's running on a server somewhere on the internet), the input is instead gathered from you before you run the program. See the button marked "stdin", on the first page ( https://ideone.com/ ) ? Push it. Then you can enter the input for cin.

If you don't supply anything, ideone will supply something for you. Could be anything. It's not random.
Last edited on
Presumably if you don't supply any input, the cin >> will fail with an end-of-file condition and number will be unchanged. Since it was not initialised, it contains garbage.
What Chervill said. I've no idea what happens on ideone if you don't provide the input. They could do whateve rthey like, really.
Thank you guys that was very helpful..
Topic archived. No new replies allowed.