首页 > 解决方案 > 编码时更改样式代码功能VScode时间优化

问题描述

我的目标是将函数更改为处理函数返回值的格式:例如;处理函数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-codecoding-style

解决方案


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

*见评论


推荐阅读