-
Compiler Question
I have a question its more of a curiosity thing really. When I compile the code below and make an exe the program works differently depending on the compiler I use. Yet the code is exactly the same. Anyone know why?
Code:
#include <iostream>
#include <string>
using namespace std;
int main() {
string y;
getline(cin,y);
cout << y;
return 0;
}
When I compile that with VC++, it prompts me to enter a value. After I type whatever in and press enter, I have to press Enter once again for the cout statement to work.
But when compiled in Dev C++ , it works properly and the cout statement executes as soon as I hit enter. Any idea why they work differently if its the same exact code?
-
VC++ has a bug in getline that requires you to hit return twice.
-Prelude
-
Thank You:) !! It was driving me nuts wondering hehe.