小编A. *_*pta的帖子

如何将#ifndef与宏参数一起使用?

我在header.h中有一个简单的代码 -

#define SWAP(a, b)  {a ^= b; b ^= a; a ^= b;} 
Run Code Online (Sandbox Code Playgroud)

这个header.h包含在code.c文件中,但我的要求是 - 我希望首先检查SWAP,如下所示 -

#ifndef SWAP(a, b)
#define SWAP(a, b)  {a ^= b; b ^= a; a ^= b;}
#endif
Run Code Online (Sandbox Code Playgroud)

这是正确的还是我不必将参数提供给第一行?

c c++ macros c++11

4
推荐指数
1
解决办法
2042
查看次数

Unix命令grep只有一个以"xyz ...."开头的子字符串直到第一个空格?

我有一个文字:

这是我的= test和class = 76

这是我的= test和class = 78

这是我的= test2和class = 76

这是我的= test3和class = 75

这是我的= test1和class = 79.

我想grep所有以"class ="开头的单词,而不打印输出应该是整行的值:

class=76
class=78
class=76
class=75
class=79
Run Code Online (Sandbox Code Playgroud)

任何可以帮助我的命令?

我试过这个:

grep -E '(^|\s+)class=(?=\s|$)' file
Run Code Online (Sandbox Code Playgroud)

但没有得到任何输出.

regex unix grep

0
推荐指数
1
解决办法
42
查看次数

标签 统计

c ×1

c++ ×1

c++11 ×1

grep ×1

macros ×1

regex ×1

unix ×1