-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path272.c
55 lines (51 loc) · 1.14 KB
/
272.c
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
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FIRST 0x1
#define SECOND 0x2
int main(int argc, char const **argv)
{
char line[0xFF];
char output[0xFF];
char *pIn;
char *pOut;
int line_length;
int i;
int state;
int pos;
state = FIRST;
while(fgets(line, 0xFF, stdin))
{
pos = 0;
line_length = strlen(line);
pIn = &line[0];
pOut = &output[0];
for(; *pIn; ++pIn, ++pOut)
{
if(*pIn == '\"')
{
switch (state) {
case FIRST:
*pOut = '`';
++pOut;
*pOut = '`';
state = SECOND;
break;
case SECOND:
*pOut = '\'';
++pOut;
*pOut = '\'';
state = FIRST;
break;
}
}
else
{
*pOut = *pIn;
}
}
*pOut = '\0';
printf("%s", output);
}
return 0;
}