阅读背景:

使用宏来定义两个局部变量但具有相同的地址

来源:互联网 

Code as below:

代码如下:

#include"stdio.h"

#define MySTRING(ident, str) \
        ({\
                char str_##ident[16]; \
                memset((char *)str_##ident, 0x00, sizeof(str_##ident)); \
                memcpy(str_##ident, (str), strlen((str))); \
                str_##ident; \
        })

int main(int argc, char **argv)
{
        printf("%u, %u\n", MySTRING(qw, "1.1.1.1"), MySTRING(er, "2.2.2.2"));
}
#include"stdio.h"

#de



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: