## 用于结构体的定义

来源:互联网 发布:帝国cms微信支付接口 编辑:程序博客网 时间:2024/09/21 08:53
  • 宏定义:在嵌入式代码中比较常用,具体使用可看MFC的框架部分
  • ##:起连接作用,对于嵌入式代码,##运算符是比较常用的

/*************************************************************************    > File Name: ##3.c    > Author: ma6174    > Mail: ma6174@163.com     > Created Time: 2017年10月23日 星期一 12时27分14秒 ************************************************************************/#include<stdio.h>#define STRUCT(type)\    typedef struct _tag_##type type ;\    struct _tag_##typeSTRUCT(Student){    char* name ;    int id ;};int main(void){    Student stuArr[5] ;    stuArr[1].name = "zhangsna" ;    stuArr[1].id = 14044201 ;    stuArr[3].name = "Z.J" ;    stuArr[3].id = 14044202 ;    printf("%s\t %d\n",stuArr[1].name,stuArr[1].id);    printf("%s\t %d\n",stuArr[3].name,stuArr[3].id);    return 0;}
原创粉丝点击