//2022年2月13日12:15:52
#include <stdio.h>
#include <string.h>
typedef struct
{
int age;
char name[20];
float score;
}student1;
void Inputstudent1(student1 * p);
void Outputstudent1(student1 ss);
int main(void)
{
student1 stu;
Inputstudent1(&stu); //对结构体变量输入,必须发送地址
Outputstudent1(stu);
return 0;
}
void Inputstudent1(student1 * p) //p只占4个字节
{
p->age = 10;
strcpy(p->name,"法外狂徒张三");
p->score = 68.3;
}
void Outputstudent1(student1 ss)
{
printf("%d %s %f",ss.age,ss.name,ss.score);
}
通过函数完成对结构体变量的输入和输出
最新推荐文章于 2023-10-07 06:00:00 发布