C++
x
47
1
2
3
4
using std::cout;
5
using std::cin;
6
using std::string;
7
8
void word_sentence_counter(const string&){ cout << "word_sentence_counter\n"; }
9
int m_letters_counter(const string&, int) { cout << "m_letters_counter\n"; return 0; }
10
11
int main()
12
{
13
string text;
14
cout << "Enter: ";
15
cin >> text;
16
bool t = true;
17
while(t)
18
{
19
int c;
20
cout << "1:count words and sentences\n2:count m-letters words in text\n";
21
cout << "3:count a word in sentence\n4:remove a word\n";
22
cin >> c; //not working
23
switch (c)
24
{
25
case 1:
26
{
27
word_sentence_counter(text);
28
break;
29
}
30
case 2:
31
{
32
int m;
33
cout << "enter m: ";
34
cin >> m;
35
int result = m_letters_counter(text, m);
36
cout << result;
37
}
38
default:
39
{
40
t = false;
41
break;
42
}
43
}
44
}
45
return 0;
46
}
47
$ g++ prog.cc -Wall -Wextra -std=c++98 -pedantic
Stdin
a
1
2
999
Start
prog.cc: In function 'int main()': prog.cc:37:13: warning: this statement may fall through [-Wimplicit-fallthrough=] 37 | } | ^ prog.cc:38:13: note: here 38 | default: | ^~~~~~~
Enter: 1:count words and sentences 2:count m-letters words in text 3:count a word in sentence 4:remove a word word_sentence_counter 1:count words and sentences 2:count m-letters words in text 3:count a word in sentence 4:remove a word enter m: m_letters_counter 0
0
Finish