0
点赞
收藏
分享

微信扫一扫

通过函数完成对结构体变量的输入和输出

dsysama 2022-02-13 阅读 72
//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);
}
举报

相关推荐

0 条评论