更改样式代码功能VScode编码时的时间优化

问题描述 投票:0回答:1

我的目标是将函数更改为处理函数返回值的格式:例如 ;处理函数scanf()

Return value of scanf : The value EOF is returned if the end of input is reached before
       either the first successful conversion or a matching failure occurs.
       EOF is also returned if a read error occurs, in which case the error
       indicator for the stream (see ferror(3)) is set, and errno is set to
       indicate the error.

因此

scanf("%d\n",&i);

将更改为

#define RVAL(exp) do {if ((exp) == -1) { perror (#exp); exit(1); }} while (0)
...
RVAL(scanf("%d\n",&i));

因此,我希望尽快完成此操作意味着:所以我要做的是查找“ scanf”的出现并将其替换为"RVAL(scanf"但问题是我必须添加另一个右括号

可以快速完成吗?使用技术?还是风格?其中每当我输入scanf();时,其替换的女巫rval(scanf());

visual-studio-code coding-style
1个回答
0
投票

如果格式字符串中没有太多,则可以将正则表达式与(scanf([^)] *))一起使用;并替换为rval(\ 1);

*查看评论

© www.soinside.com 2019 - 2024. All rights reserved.