-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoctrl.cpp
More file actions
34 lines (29 loc) · 696 Bytes
/
Copy pathnoctrl.cpp
File metadata and controls
34 lines (29 loc) · 696 Bytes
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
/* will ignore the control char. */
#include <iostream>
using namespace std;
#define isctrl(c) (c >= 0 && c <= 31 && c !='\n' && c != '\t')
int main(){
char c, prec = 0;
long nctrl = 0, nchar = 0;
while (cin.get(c)){
cout << isctrl(c);
if (isctrl(c)){
nctrl++;
nchar = 0;
}
else{
if(nctrl > 0){
cout.put(' ');
nctrl = 0;
}
switch(++nchar){
case 1: break;
case 2: cout.put(prec);
default: cout.put(c);
/* the current one */
}
prec = c;
}
}
return 0;
}