This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
NG_2024_Stanislav_Mykhailenko/Lesson_2/Task_4/main.cpp
Stanislav Mykhailenko a9b7ecf20c
Add Lesson 2
2024-06-24 18:19:29 +03:00

22 lines
404 B
C++

#include <iostream>
using namespace std;
int main()
{
char str[256];
cout << "Enter some string: ";
cin.getline(str, 256);
int words = 1;
for (int character = 0; character < 256; ++character) {
if (str[character] == ' ')
++words;
else if (str[character] == 0)
break;
}
cout << "Number of words: " << words << endl;
return 0;
}