0

I was working on an example for this answer and I noticed that http://ideone.com will let me read till EOF from cin but Visual Studio 2015 will not.

For example, given the program:

string i;

while(cin >> i) cout << i << endl;

I can give the input:

Lorem Ipsum

And http://ideone.com will terminate: http://ideone.com/22uNOr

Visual Studio 2015 will continue waiting for input however until I press Ctrl + Z and hit Enter

Is this a gcc/Visual Studio difference or just something http://ideone.com is doing?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
  • 2
    It's an ideone thing. It pipes the input to your program, it doesn't enter it interactively. (How would the interactive console know that no more input will be coming?) – molbdnilo Apr 15 '16 at 13:46
  • @molbdnilo That's what I suspected... I just wasn't sure if gcc would let me extract to the end of `cin`, and since I don't have gcc available locally I thought I'd ask. Could you put that down as an answer? – Jonathan Mee Apr 15 '16 at 13:56
  • @JonathanMee It's the same at coliru BTW. – πάντα ῥεῖ Apr 15 '16 at 14:09
  • @πάνταῥεῖ I suppose so but, at least with http://coliru.stacked-crooked.com/ I'm doing the pipe myself. There isn't an indication of how http://ideone.com takes in the string I put in the "Input" text-box. – Jonathan Mee Apr 15 '16 at 14:13
  • @MartjinPieters Are they burninating the ideone tag? Cause if not it really does seem to have a place in this question? – Jonathan Mee Aug 12 '17 at 02:10

1 Answers1

0

On http://ideone.com you can provide input on the "input" tab. Anything inputted into this box will be fed to cin appended with an eof character.

For example if you do:

while (cin.get() != decltype(cin)::traits_type::eof());

On your local machine that will never come back till you press Ctrl + z and press Enter But on http://ideone.com it will always return after parsing everything typed into the "input" tab.

Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288