g++ -Wall -o "exercise9_1" "exercise9_1.cpp" (in directory: /home/stephen/Desktop/untitled folder)
exercise9_1.cpp:7: error: variable or field ‘getn’ declared void
exercise9_1.cpp:7: error: ‘string’ was not declared in this scope
exercise9_1.cpp:7: error: ‘wings’ was not declared in this scope
exercise9_1.cpp:8: error: variable or field ‘count’ declared void
exercise9_1.cpp:8: error: ‘string’ was not declared in this scope
exercise9_1.cpp:8: error: expected primary-expression before ‘int’
exercise9_1.cpp: In function ‘int main()’:
exercise9_1.cpp:15: error: ‘getn’ was not declared in this scope
exercise9_1.cpp:16: error: ‘count’ was not declared in this scope
exercise9_1.cpp: At global scope:
exercise9_1.cpp:28: error: default argument for ‘int& wordcount’ has type ‘int’
exercise9_1.cpp: In function ‘void count(std::string, int&)’:
exercise9_1.cpp:36: warning: comparison with string literal results in unspecified behaviour
exercise9_1.cpp:36: error: ISO C++ forbids comparison between pointer and integer
exercise9_1.cpp:36: warning: suggest parentheses around assignment used as truth value
exercise9_1.cpp:41: warning: comparison with string literal results in unspecified behaviour
exercise9_1.cpp:41: error: ISO C++ forbids comparison between pointer and integer
exercise9_1.cpp:41: warning: comparison with string literal results in unspecified behaviour
exercise9_1.cpp:41: error: ISO C++ forbids comparison between pointer and integer
Compilation failed.
I don't know if it will make a difference or not, but in your function prototypes, I'd suggest removing your variable names and values. I don't know if it should throw an error, but I know that I was taught to just use the data types in the prototypes.
I don't know if it will make a difference or not, but in your function prototypes, I'd suggest removing your variable names and values. I don't know if it should throw an error, but I know that I was taught to just use the data types in the prototypes.
Nope, makes no sense. The (default) values on line 7 is only for the protoype. Later on line 27 it makes no sense.
Move line 8 before line 6 and those errors will go away.
i typecast the length of the string in-putted and made it an int.
The while loop is if counter is less than the string length so it keeps counting up until counter is greater than the length and then it breaks.
Um the if statement is just declaring that if there is more than one space char then its not a word so it exits
the second one counts location P as a letter and then P+1 as a space then its a word.i guess