结构体
结构体指针
typedef的使用
typedef的作用就是起别名
pstu 等价于 struct student *
提问:把代码附上,加上问题说明
提问时,我这个问题,我是不是可以写一个例子去帮我理解没有理解清楚的地方
为什么要对int起别名,为了代码即注释
#include <stdio.h> //给结构体类型起别名,叫stu,起了结构体指针类型的别名,叫pstu typedef struct student { int num; char name[20]; char sex; }stu, * pstu; typedef int INTEGER; int main() { stu s= { 1001,"wangle",'M' }; pstu p;//stu* p1,那么p1也是一个结构体指针 INTEGER i = 10; p = &s; printf("i=%d,p->num=%d\n", i, p->num); return 0; }
c++的引用讲解

说明要进行强制类型转换
0x00cc5468

#include <stdio.h> //给结构体类型起别名,叫stu,起了结构体指针类型的别名,叫pstu typedef struct student { int num; char name[20]; char sex; }stu, * pstu; typedef int INTEGER; int main() { stu s= { 1001,"wangle",'M' }; pstu p;//stu* p1,那么p1也是一个结构体指针 INTEGER i = 10; p = &s; printf("i=%d,p->num=%d\n", i, p->num); return 0; }

浙公网安备 33010602011771号