## 用于结构体的定义

版权声明:本文为博主原创文章,未经博主允许不得转载。。。。没有所谓的原创,只是总结而已 https://blog.csdn.net/W__L__/article/details/78512544

如需更好的展示博客内容,请点我!

  • 宏定义:在嵌入式代码中比较常用,具体使用可看MFC的框架部分
  • ##:起连接作用,对于嵌入式代码,##运算符是比较常用的

/*************************************************************************
    > File Name: ##3.c
    > Author: ma6174
    > Mail: [email protected] 
    > Created Time: 2017年10月23日 星期一 12时27分14秒
 ************************************************************************/

#include<stdio.h>

#define STRUCT(type)\
    typedef struct _tag_##type type ;\
    struct _tag_##type

STRUCT(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;
}

猜你喜欢

转载自blog.csdn.net/W__L__/article/details/78512544