Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstring>
- using namespace std;
- int countWords(char *sentence);
- int main()
- {
- const int size=80;
- char word[size];
- double average=0;
- cout<<"Enter words less than " <<size-1<<" characters."<<endl;
- cin.getline(word, size);
- cout <<"There are "<<countWords(word)<<" words in the sentence."<<endl;
- return 0;
- }
- int countWords(char *sentence)
- {
- int words= 1;
- while(*sentence != '