webstorm 能不能修改注释风格
答案:1 悬赏:0 手机版
解决时间 2021-03-20 11:13
- 提问者网友:沉默菋噵
- 2021-03-19 17:25
webstorm 能不能修改注释风格
最佳答案
- 五星知识达人网友:渡鹤影
- 2021-03-19 18:43
可以的,给你参考一下我的
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
56
57
58
#include
#define OK 0
#define ERR 1
typedef enum {NONE, C_STYLE, CPP_STYLE, STR, END_OF_FILE } STATE;
STATE ProcessStateNone(char ch, FILE **fpIn, FILE **fpOut);
STATE ProcessStateCPPStyle(char ch, FILE **fpIn, FILE **fpOut);
STATE ProcessStateCStyle(char ch, FILE **fpIn, FILE **fpOut);
STATE ProcessStateSTR(char ch, FILE **fpIn, FILE **fpOut);
void ProcessStateEOF(STATE state, FILE **fpOut);
int main(void)
{
FILE *fpIn, *fpOut;
char ch;
STATE state = NONE;
fpIn = fopen("D:/testFile.c","r");
if(NULL == fpIn)
{
printf("can't open source file\n");
fclose(fpIn);
return ERR;
}
fpOut = fopen("D:/testFile2.c","w");
if(NULL == fpOut)
{
printf("can't open destination file\n");
fclose(fpIn);
fclose(fpOut);
return ERR;
}
ch = fgetc(fpIn);
while(ch != EOF)
{
switch(state)
{
case NONE: state = ProcessStateNone(ch, &fpIn, &fpOut);break;
case C_STYLE: state = ProcessStateCStyle(ch, &fpIn, &fpOut);break;
case CPP_STYLE: state = ProcessStateCPPStyle(ch, &fpIn, &fpOut);break;
case STR: state = ProcessStateSTR(ch, &fpIn, &fpOut);break;
}
}
//default
stateTemp = STR;
fputc(ch, *fpOut);
return stateTemp;
}
void ProcessStateEOF(STATE state, FILE **fpOut)
{
if(state == CPP_STYLE) // c++ 风格注释处理
{
fputc('*', *fpOut);
fputc('/', *fpOut);
return;
}
}
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
56
57
58
#include
#define OK 0
#define ERR 1
typedef enum {NONE, C_STYLE, CPP_STYLE, STR, END_OF_FILE } STATE;
STATE ProcessStateNone(char ch, FILE **fpIn, FILE **fpOut);
STATE ProcessStateCPPStyle(char ch, FILE **fpIn, FILE **fpOut);
STATE ProcessStateCStyle(char ch, FILE **fpIn, FILE **fpOut);
STATE ProcessStateSTR(char ch, FILE **fpIn, FILE **fpOut);
void ProcessStateEOF(STATE state, FILE **fpOut);
int main(void)
{
FILE *fpIn, *fpOut;
char ch;
STATE state = NONE;
fpIn = fopen("D:/testFile.c","r");
if(NULL == fpIn)
{
printf("can't open source file\n");
fclose(fpIn);
return ERR;
}
fpOut = fopen("D:/testFile2.c","w");
if(NULL == fpOut)
{
printf("can't open destination file\n");
fclose(fpIn);
fclose(fpOut);
return ERR;
}
ch = fgetc(fpIn);
while(ch != EOF)
{
switch(state)
{
case NONE: state = ProcessStateNone(ch, &fpIn, &fpOut);break;
case C_STYLE: state = ProcessStateCStyle(ch, &fpIn, &fpOut);break;
case CPP_STYLE: state = ProcessStateCPPStyle(ch, &fpIn, &fpOut);break;
case STR: state = ProcessStateSTR(ch, &fpIn, &fpOut);break;
}
}
//default
stateTemp = STR;
fputc(ch, *fpOut);
return stateTemp;
}
void ProcessStateEOF(STATE state, FILE **fpOut)
{
if(state == CPP_STYLE) // c++ 风格注释处理
{
fputc('*', *fpOut);
fputc('/', *fpOut);
return;
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯