0

What is missing from my code? 😔

Determine the number of words in a phrase. https://code.sololearn.com/cfe9uD0T7o21/?ref=app

3rd Jun 2019, 11:33 PM
El Patriarcado
El Patriarcado - avatar
5 Antworten
0
Miriam Rosa⚘ 1) You have cycle wich runs until i less then lenth of the phrase. 2) Inside of cycle you are adding whitespase to the string which will increase lenth of this string. 3) if uses phrase1[i] which should give you char not string 4) you are using 'and' instead && in if, I am not sure it will work in cpp 1 and 2 will work really badly together
4th Jun 2019, 1:21 AM
Dima Makieiev
Dima Makieiev - avatar
+ 2
Remove most of those blank spaces and it works...
4th Jun 2019, 12:18 AM
Bodan Talev
Bodan Talev - avatar
0
Miriam Rosa⚘ I think sololearn compiler doesnt recognises getline(cin,phrase1); as input(no input prompt displayed by playground). If you try cin>>phrase1 at least it asks for input;
4th Jun 2019, 12:14 AM
Dima Makieiev
Dima Makieiev - avatar
0
I took care of most of the errors, which only brought up another one. Unfortunately I dont know enough C++ to fix it😅 Perhaps Dima Makieiev will know whats up? https://code.sololearn.com/cOTjp3yEKOsB/?ref=app
4th Jun 2019, 4:34 AM
Trigger
Trigger - avatar