-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe6.cpp
48 lines (41 loc) · 796 Bytes
/
e6.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Created by martin on 18/01/2022.
//
// Enter text ,,,,? whitespace (? to quit) " - don't use the as-if rule." ??!XXX
#include "../std_lib.h"
using namespace std;
int main ()
{
cout << "Enter text to replace punctuation with whitespace (q to quit): " << endl;
for (string line ; getline(cin, line) ;)
{
if (line.size() == 1 && tolower(line.at(0) == 'q'))
{
exit(EXIT_SUCCESS);
}
bool in_quote = false;
for (int i {0} ; i < line.size() ; ++i)
{
switch (line.at(i))
{
case '.':
case ';':
case ',':
case '?':
case '-':
case '\'':
if (!in_quote)
{
line.at(i) = ' ';
}
break;
case '\"':
in_quote = !in_quote;
break;
default:
break;
}
}
cout << line << endl;
}
}