案例1:
#include <stdio.h>
#include <string.h>
#include <malloc.h>
typedef int zhangsan; //为int在多取一个名字 zhangsan等价于int
struct Student{
int sid;
char sname[100];
char sex;
} ST;
int main() {
int i = 10; //等价于zhangsan i=10
zhangsan j = 20;
printf("%d", j);
char c = '\0';
printf("%c\n", c);
printf("c输出得:%d\n", (int)c);
struct Student st;
struct Student * ps = &st;
ST.sid=12;
ST.sex = 'n';
strcpy_s(ST.sname , "lisi");
printf("%c\n", ST.sex);
printf("%d\n", ST.sid);
printf("%s\n", ST.sname);
while (true){}
return 0;
}
案例2:
#include <stdio.h>
#include <string.h>
#include <malloc.h>
typedef int zhangsan; //为int在多取一个名字 zhangsan等价于int
typedef struct Student{
int sid;
char sname[100];
char sex;
} ST;
int main() {
int i = 10; //等价于zhangsan i=10
zhangsan j = 20;
printf("%d", j);
char a = '\0';
printf("%c\n", a);
struct Student st;
struct Student * ps = &st;
ST st2; //等价于 struct Student st;
st2.sid = 12;
st2.sex = 'n';
strcpy_s(st2.sname, "lisi");
printf("%c\n", st2.sex);
printf("%d\n", st2.sid);
printf("%s\n", st2.sname);
while (true) {}
return 0;
}
案例3:
#include <stdio.h>
#include <string.h>
#include <malloc.h>
typedef int zhangsan; //为int在多取一个名字 zhangsan等价于int
typedef struct Student{
int sid;
char sname[100];
char sex;
} * PST; //等价于struct Student *
int main(void) {
struct Student st;
PST ps = &st;
ps->sid = 99;
printf("%d\n", ps->sid);
while (true) {}
return 0;
}
案例4:
#include <stdio.h>
#include <string.h>
#include <malloc.h>
typedef int zhangsan; //为int在多取一个名字 zhangsan等价于int
typedef struct Student
{
int sid;
char sname[100];
char sex;
} *PSTU,STU; //PSTU等价于struct Student * (PSTU表示结构体指针),STU等价于struct Student st (结构体本身)
int main(void) {
STU st;
PSTU ps = &st;
ps->sid = 99;
printf("%d\n", ps->sid);
while (true) {}
return 0;
}