Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <string.h>
- using namespace std;
- const int N= 100;
- int Words(char str[N]){
- int number_words=0;
- char *pstr;
- pstr=strtok(str," ");
- while (pstr!=NULL)
- {
- pstr=strtok(NULL," ");
- number_words++;
- }
- return (number_words);
- }
- int main(int argc, char** argv) {
- setlocale(LC_ALL, "RUSSIAN");
- char str[N];
- cout << "Введите текст: ";
- cin.getline ( str, N);
- cout << "В тексте "<< Words(str)<<" слов(а)." <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement