#define MAR_VA 100
const int Con_va = 100;
...
/*定义两个数组*/
...
for(int i = 0;i < 10;++i)
{
mar_arr[i] = MAR_VA;
con_arr[i] = Con_va;
}
printf("%d\n", __STDC__);
printf("%d\n", __STDC_VERSION__);
#define err(flag) \
if(flag) \
printf("Correctly")
#define SWAP1(a, b) (a += b, b = a - b, a -= b)
#define SWAP2(x, y) {x ^= y; y ^= x; x ^= y}
int v1 = 10; int v2 = 20; SWAP1(v1, v2); SWAP2(v1, v2);//报错
#define SWAP3(x ,y) do{ \
x ^= y; y ^= x; x ^= y; \
}while(0)
#define CMP(x, y) (x > y ? x : y)
...
int x = 100, y = 200;
int result = CMP(x, y++);
printf("x = %d, y = %d, result = %d\n", x, y, result);
int result = (x > y++ ? x : y++);
#define MULTI(x, y) (x * y) ... int x = 100, y = 200; int result = MULTI(x+y, y);
int result = ((x+y) * (y));
int result = MULTI(MULTI(x, y), y);
int result = ((((x) * (y))) * (y));
#define HCMP(x, y) printf(#x" is equal to" #y" ? %d\n", (x) == (y)) ... int x = 100, y = 200; HCMP(x, y);
printf("x is equal to y ? %d\n", (100) == (200));
/* 下方会说到的 # 预处理指示器,这里先用,实在看不懂,可以自己动手尝试 */ #define WHERE_AM_I #__LINE__ " lines in " __FILE__ ... fputs(WHERE_AM_I, stderr);
/* 常理上这应该能工作,但是编译器非说这错那错的 */ /* 好在有前人踏过了坑,为我们留下了解决方案 */ #define DEPAKEGE(X) #X #define PAKEGE(X) DEPAKEGE(X) #define WHERE_AM_I PAKEGE(__LINE__) " lines in " __FILE__ ... fputs(WHERE_AM_I, stderr);
#define MERGE(x, y) have_define_ ## (x + y) #define MERGE(x, y) have_define_##(x + y) ... result = MERGE(1, 3);
result = have_define_1 + 3;
inline int func_0(int arg_1, int arg_2) { return arg_1 + arg_2; }
inline int func_1(int arg_1, int arg_2) { return arg_1 - arg_2; }
inline int func_2(int arg_1, int arg_2) { return arg_1 * arg_2; }
inline int func_3(int arg_1, int arg_2) { return arg_1 / arg_2; }
#define CALL(x, arg1, arg2) func_##x(arg1, arg2)
...
printf("func_%d return %d\n",0 ,CALL(0, 2, 10));
printf("func_%d return %d\n",1 ,CALL(1, 2, 10));
printf("func_%d return %d\n",2 ,CALL(2, 2, 10));
printf("func_%d return %d\n",3 ,CALL(3, 2, 10));
#define CAT(temp, i) (cat##i)
//...
for(int i = 0;i < 5;++i)
{
int CAT(x,i) = i*i;
printf("x%d = %d \n",i,CAT(x,i));
}
#define WHERE(value_name, line) #value_name #line ... puts(WHERE(x, __LINE__)); //x = 11
#if defined(__cplusplus) || defined(_cplusplus)
extern "C" {
#endif
/**主体代码**/
#if defined(__cplusplus) || defined(_cplusplus)
}
#endif
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有