how can a user be able to type what ever he wants such as " i went to the park...", i tried to do it but with my string variable it only read the first word typed in, such as i in this case.
/*
Purpose: Have user input lines of code until sentinel value has been found. Output results
Name: Saith
Date: 2/4/11
*/
#include<iostream>
#include<string>
using namespace std;
int main() {
string line, paragraph; // strings are initialized as empty, no need to assign them.
while(line != "done"){
paragraph += line;
cout << "Enter newest line.\n";
getline(cin, line);
}
cout << paragraph;
return 0;
}
Here is a sample that I just created using user input.