www.digitalmars.com         C & C++   DMDScript  

c++ - cin with a string

This compiles but does not execute:
//(code has been shortened on purpose)

#include <iostream.h>
#include <string>

string something;

int main()
{

cout << "Enter your name: ";
cin >> something;

}

This compiles and executes properly:

#include <iostream.h>
#include <string>

char something[40];

int main()
{

cout << "Enter your name: ";
cin >> something;

}

Why won't a string work with cin?
Mar 16 2003