本文主要是介绍17.2结构体重新赋值,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
#include<stdio.h>
#include<string.h>typedef struct Student
{int id; //学号char name[10]; //姓名int age; //年龄
}Student;int main()
{//输入输出Student fire = { 0 };//输入printf("请输入学号、年龄、姓名>");scanf("%d %d %s", &fire.id, &fire.age, fire.name);//重新赋值...fire.id = 0;fire.age = 22;strcpy(fire.name, "小斌");//整体清零memset(&fire, 0, sizeof(Student));//整体对结构体赋值fire = (Student){999,"xiaobin",99 };printf("请输入学号:%d、年龄:%d、姓名:%s>",fire.id,fire.age,fire.name);return 0;
}
这篇关于17.2结构体重新赋值的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!