Fix Lesson 2 Task 4

This commit is contained in:
Stanislav Mykhailenko 2024-07-18 14:19:09 +03:00
parent cae32898fb
commit 3fcab8541d
GPG key ID: 1E95E66A9C9D6A36

View file

@ -10,10 +10,10 @@ int main()
int words = 1; int words = 1;
for (int character = 0; character < 256; ++character) { for (int character = 0; character < 256; ++character) {
if (str[character] == ' ') if (str[character] == 0)
++words;
else if (str[character] == 0)
break; break;
else if (str[character] < 'A' || str[character] > 'z')
++words;
} }
cout << "Number of words: " << words << endl; cout << "Number of words: " << words << endl;