Finding words, phrases and sentences. Help!

Hey guys I need help in counting the number of words in this input (use isspace( ) to find breaks between words), the phrases, and the sentences. Can someone please help me out ? Here is my code so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <string>
#include <cctype>

int main()
{
    std::string result ;
    std::string line ;
	std::string length;
    std::cout << "Enter text: " << std::endl;
	
    while (std::getline(std::cin, line) && !line.empty() )
		{
			result += line + " " ;
	    }
    std::cout << result << '\n';
	
	return 0;
}
This looks like code you got from someone else helping you do a different assignment. What kind of ideas did you have to approach the problem?
oops ya your right my bad here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
    string result ;
    string line ;
	
    cout << "Enter text: " << std::endl;
	
    while (getline(cin, line) && !line.empty() )
		{
			result += line + " " ;
	    }
    cout << result << '\n';
	
}


okay i was wondering where should i even start? I was thinking like doing a
if(result != ispunct())
words++
but it dosent work out??
Topic archived. No new replies allowed.