结构体加typedef与不加typedef的使用区别

来源:互联网 发布:数据库精品课程 王珊 编辑:程序博客网 时间:2024/04/29 13:03

1.加了typedef使用例子如下:

#include <stdio.h>
#include <stdlib.h>
typedef struct person{
    int age;
    int name;
}stu3;


int main()
{
stu3 stu4;
stu4.name=7;
    printf("%ld\n",stu4.name);
    return 0;
}

2.不加typedef使用例子如下:

#include <stdio.h>
#include <stdlib.h>
 struct person{
    int age;
    int name;
}stu3;


int main()
{
struct person stu4;
stu4.name=7;
stu3.age=8;
    printf("%ld %ld\n",stu4.name,stu3.age);
    return 0;
}

0 0
原创粉丝点击