帮我修改这个代码 我想用函数输入输出结构体 但是自己不会

来源:互联网 发布:汇友行情软件 编辑:程序博客网 时间:2024/05/22 18:56
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct student{
char *name;
-
int id;
int age;
}s1;
void enter(struct student *m)
{
char *name1;
int id1 = 0;
int age1 = 0;
scanf_s("%s\n", name1);
scanf_s("%d\n", id1);
scanf_s("%d\n", age1);
strcpy_s(m->name, name1);
(*m).id = id1;
(*m).age = age1;
}
void  output(struct student n)
{
printf("%s\n", n.name);
printf("%d\n", n.id);
printf("%d\n", n.age);
}
int main()
{
enter(&s1);
output(s1);
system("pause");
return 0;
}
阅读全文
0 0
原创粉丝点击