Hey y'all I am new to c++ and i needed a little help with this code. I am suppose modify my program to read an arbitrary number of lines from the console until a blank line is encountered. Then append the lines together, and output them to the console. Heres what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <string>
usingnamespace std;
int main(void)
{
string line, line2, jLines;
cout << "Please enter your first line of text: " << endl;
getline(cin, line);
cout << "Please enter your second line of text: " << endl;
getline(cin, line2);
jLines = line + " " + line2;
cout << jLines << endl;
return 0;
}
#include <iostream>
#include <string>
usingnamespace std;
int main(void)
{
string line = "a";
string result;
while (line.length() != 0)
{
cout << "Enter text line: " << endl;
getline(cin, line);
result = result + " " + line;
}
cout << result << endl;
return 0;
}
but now I need to modify the program to count the number of words in the input (use isspace( ) to find breaks between words), and the number of phrases (as delineated by punctuation marks), and the number of sentences (delineated by a period)?
#include <iostream>
#include <string>
int main()
{
std::string result ;
std::string line ;
while ( std::getline(std::cin, line) && !line.empty() )
result += line + " " ;
std::cout << result << '\n' ;
}
but now I need to modify the program to count the number of words in the input (use isspace( ) to find breaks between words), and the number of phrases (as delineated by punctuation marks), and the number of sentences (delineated by a period)?