PDA

View Full Version : Reading sentences from command line


kansurr
11-15-2007, 09:22 PM
Hi,

What is the best way to read a sentence from the command line using C++. I was to read everything up to a 'enter'. Please let me know of the correct includes needed as well. thanks for your help.

Inigoesdr
11-15-2007, 09:53 PM
#include <iostream>
#include <string>
using namespace std;

int main()
{
string line;
cout << "Enter your string: ";
getline(cin, line);
cout << "You entered: " << line << endl;
return 0;
}