#include<stdio.h>
//第一种方式
struct Student
{
int age;
float score;
char sex;
};
/*//第二种方式
struct Student2
{
int age;
float score;
char sex;
}st2;
//第三种方式
struct
{
int age;
float score;
char sex;
}st3;*/
int main(void)
{
struct Student st = {80,66.6,'F'};
struct Student st2;
st2.age = 10;
st2.score = 88;
st2.sex = 'F';
printf("%d %f %c\n",st.age,st.score,st.sex);
printf("%d %f %c\n",st2.age,st2.score,st2.sex);
return 0;
}
郝斌的C语言基础 151~154 结构体的赋值和初始化
最新推荐文章于 2025-04-08 22:05:43 发布