1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > typedef struct student 和 struct student 的区别

typedef struct student 和 struct student 的区别

时间:2021-04-02 21:47:40

相关推荐

typedef struct student 和 struct student 的区别

typedef struct student

{

int num;

struct student *next;

}student;

struct student

{

int num;

struct student *next;

};

第二个struct student是定义了一个student结构体,

第一个是用typedef 把 struct student 这个结构体类型名字重新定义为student,也就是说struct student和student表示同一个事物,都是一个类型的标识符,

比如 typedef int zhengshu; 就是你把整型int重命名为zhengshu,下面定义:int i; 和 zhengshu i; 两句就是等价的了

例程:

#define ListSize 10

typedef int DataType;

typedef struct{

DataType data【ListSize】;

int length;

}SeqList;

SeqList *L;

L->data =

L->length =

下面两个例程则是他们应用上的区别:

例1:不使用typedef,

//#include <apue.h>

#include <stdio.h>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。