#include<stdio.h> #define NAME_LEN 64 struct student{ char name[NAME_LEN]; int height; float weight; long schols; }; void hiroko(struct student *std) { if ((*std).height < 180) (*std).height = 180; if ((*std).weight > 80 ) (*std).weight = 80; } int main(void) { struct student sanaka = {"Sanaka", 175, 85, 73000}; hiroko(&sanaka); printf("姓名 = %s\n", sanaka.name); printf("身高 = %d\n", sanaka.height); printf("体重 = %.lf\n", sanaka.weight); printf("奖学金 = %ld\n", sanaka.schols); return 0; }
结构体和指针的用法例子
猜你喜欢
转载自blog.csdn.net/weixin_39690617/article/details/79571814
今日推荐
周排行