##号的使用

#include <stdio.h>
#define CONVERS(x) #x
//对#调用的使用
#define CALL(f,p) (printf("call function %s\n",#f),f(p))
#define NAME(n) name##n
#define STRUCT(type) typedef struct _tag_##type type;\
struct _tag_##type

STRUCT(Student)
(	
	int id;
);

int square(int n)
{
	return n*n;

}
int f1(int x)
{
	return x;
}

 //#调用的强大之处。不仅可以实现字符串的调用,同时可以实现函数的调用
int main() 
{
	/*
	HELLO WORLD
100
while
return
call function square
1.16
call function f1
2.10
	*/
	int NAME(1);// 预处理仅仅进行简单的粘连 在预编译里面实现的是int name1
	Student s1;
	int NAME(2);
	NAME(1) = 1;
	NAME(2) = 2;
	printf("%d\n", NAME(1));
	printf("%d\n", NAME(2));
	printf("%s\n", CONVERS(HELLO WORLD));
	printf("%s\n", CONVERS(100));
	printf("%s\n", CONVERS(while));
	printf("%s\n", CONVERS(return));

	struct MyStruct {
		int a;
	
	};

	printf("1.%d\n", CALL(square, 4));
	printf("2.%d\n", CALL(f1, 10));
}

##号使用范围很广阔

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值