结构体嵌套(分开定义)

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> struct scorestruct { int math; int english; } scores; struct infostruct { float height; float weight; } info; struct student { char name[20]; struct scorestruct scores; /* scorestruct 型的结构体变量 score,作为 students 结构的数据成员 */ struct infostruct info; }; // 结构体嵌套 int main() { struct student wangyu = {"Wang wu", {80, 96}, {175, 80}}; printf("wangwu's name: %s \n", wangyu.name); printf("wangwu's math scores: %d \n", wangyu.scores.math); printf("wangwu's english scores: %d \n", wangyu.scores.english); printf("wangwu's height: %.1f \n", wangyu.info.height); printf("wangwu's weight: %.1f \n", wangyu.info.weight); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines