为什么使用结构体:一些不同数据类型的集合
例一:结构体的使用
#include "stdio.h" #include "string.h" typedef struct { char name[20]; int height; float weight; long schols; }student; void hiroko(student *std) { if(std->height < 180) std->height=180; if(std->weight > 80) std->weight=80; } int main() { student sanaka={"sanaka",175,181.5,70000}; hiroko(&sanaka); printf("姓名=%s ",sanaka.name); printf("身高=%d ",sanaka.height); printf("体重=%f ",sanaka.weight); printf("奖学金=%ld ",sanaka.schols); return 0; }