【C】C语言结构体指针的语法
生活随笔
收集整理的這篇文章主要介紹了
【C】C语言结构体指针的语法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>struct AGE
{int year;int month;int day;
};struct Student
{char *name;int num;struct AGE birthday;float score;
};int main()
{// 注意寫法1與寫法2 不能混用// 寫法1struct Student* stu = NULL;stu = (struct Student *)malloc(sizeof(struct Student));(*stu).num = 12;printf("%d\n", (*stu).num);// 寫法2struct Student *stu1 = (struct Student *)malloc(sizeof(struct Student));stu1->name = "jack";printf("%s\n", stu1->name);return 0;
}
轉載于:https://www.cnblogs.com/jzsg/p/10946315.html
總結
以上是生活随笔為你收集整理的【C】C语言结构体指针的语法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: bind 0.0.0.0的作用是什么呢?
- 下一篇: 直播源码中有哪些网络协议需要注意?