日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

C语言的typedef用法

發布時間:2025/3/15 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C语言的typedef用法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

案例1:?

#include <stdio.h> #include <string.h> #include <malloc.h>typedef int zhangsan; //為int在多取一個名字 zhangsan等價于intstruct Student{int sid;char sname[100];char sex;} ST;int main() {int i = 10; //等價于zhangsan i=10zhangsan 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等價于inttypedef struct Student{int sid;char sname[100];char sex;} ST;int main() {int i = 10; //等價于zhangsan i=10zhangsan 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等價于inttypedef 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等價于inttypedef 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; }

?

總結

以上是生活随笔為你收集整理的C语言的typedef用法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。