C++ getline() Does not Work Properly in Visual C++
Asked By
10 points
N/A
Posted on - 04/13/2012
I have this simple statement that I am trying to follow from a book. The code reads:
#include <iostream>
#include <string>
Â
using namespace std;
int main()
{
string names;
cout<<"Enter your name:n";
getline(cin, names);
cout<<names<<endl;
return 0;
}
Â
I tried running it using the command line and it works. Why is getline() not working in Visual C++? Is there a possible fix for it?