-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdircasechars.cpp
More file actions
39 lines (37 loc) · 1.4 KB
/
Copy pathdircasechars.cpp
File metadata and controls
39 lines (37 loc) · 1.4 KB
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
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
int cac(char &tmpc) {
// * ? [ # ~ = %
// | & ; < > ( ) $ ` \ " ' <space> <tab> <newline>
if (tmpc == ' ' || tmpc == '(' || tmpc == ')' ||
// tmpc == '{' || tmpc == '}' ||
tmpc == '&' || tmpc == '\\' ||
tmpc == ';' || tmpc == '|' || tmpc == '<' || tmpc == '>' ||
tmpc == '$' || tmpc == '`' || tmpc == '\"' || tmpc == '\'' ||
tmpc == '*' || tmpc == '?' || tmpc == '[' || tmpc == ']' ||
tmpc == '#' || tmpc == '~' || tmpc == '=' || tmpc == '%'
) return 1;
else return 0;
}
int main(void) {
std::ifstream inc("kkk");
std::ofstream ouc("mmm");
char tmpc[1000];
char tmpd[2000];
int tmpi, tmpj;
while (inc.getline(tmpc, 1000)) {
tmpi = tmpj = 0;
for (tmpi = 0; tmpi < strlen(tmpc); tmpi++) {
if (tmpc[tmpi] == ' ') tmpd[tmpj++] = '.';
else if (cac(tmpc[tmpi]) && tmpc[tmpi] != ' ') {
tmpd[tmpj++] = '\\';
tmpd[tmpj++] = tmpc[tmpi];
}
else tmpd[tmpj++] = tmpc[tmpi];
}
tmpd[tmpj] = '\0';
ouc << tmpd << '\n';
}
}