正在加载图片...
131结构体类型变量的定义和引用 结构体类型变量的初始化和赋值 「例13.2给结构变量赋值并输出其值。 main( i struct stu int num; char *name: char sex: float score 3 boyl, boy2; boyl num=102 boyl. name="Zhang ping"; printf( input sex and scoreIn"); scan if ("%c %",&boylsex, &boylscore); boy2=boyl printf(Number=%dnName=%sn, boy2 num, boy2 name); printf("Sex=% cInscore=ofn", boy2 sex, boy2 score); 第十三章结构体与共用体第十三章 结构体与共用体 [例13.2]给结构变量赋值并输出其值。 main( ) { struct stu { int num; char *name; char sex; float score; } boy1,boy2; boy1.num=102; boy1.name="Zhang ping"; printf("input sex and score\n"); scanf("%c %f",&boy1.sex,&boy1.score); boy2=boy1; printf("Number=%d\nName=%s\n”,boy2.num,boy2.name); printf("Sex=%c\nScore=%f\n",boy2.sex,boy2.score); } 13.1 结构体类型变量的定义和引用 二、结构体类型变量的初始化和赋值
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有