Why isn't cin >> string working with Visual C++ 2010?

Ivan picture Ivan · Mar 17, 2011 · Viewed 46.2k times · Source
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    cout << "Hello World!";
}

This isn't working. Why?

Answer

Alexander Gessler picture Alexander Gessler · Mar 17, 2011

Because you forgot to #include <string>