为数据类型取别名
代码语言:javascript
复制 1 #include<stdio.h>
2
3 typedef int i; //为int再重新多取一个名字,i等价于int
4
5 typedef struct student{
6 int sid;
7 char sex;
8 }ST;//为struct student再重新多取一个名字为ST,下面有用到struct student的地方都可以用ST代替
9
10 int main(){
11 int a=10;//等价于 i a=10;
12 struct student st;//等价于ST st;
13 struct student *ps;//等价于ST *ps;
14 return 0;
15 }
代码语言:javascript
复制 1 #include<stdio.h>
2
3 typedef struct student{
4 int sid;
5 char sex;
6 }* PST,STU;//用逗号隔开,PST等价于struct student *,STU代表struct student
7
8 int main(){
9 STU st; //struct student st
10 PST ps = &st; //struct student * ps = &st;
11 return 0;
12 }