|
楼主 |
发表于 2018-12-21 14:48:57
|
显示全部楼层
#include <stdio.h>
#include <string.h>
//int InputStudent(struct Studnet *pstu);
//int OutputStudent(struct Student stu);
struct Student
{
int age;
char sex;
char name[100];
};
int InputStudent(struct Studnet *pstu);
int OutputStudent(struct Student stu);
int main()
{
struct Student st;
InputStudent(&st);
printf("%d %c %s\n", st.age, st.sex, st.name);
OutputStudent(st);
return 0;
}
int InputStudent(struct Student *pstu) //pstu只占4个字节
{
pstu->age = 10;
strcpy(pstu -> name, "张三");
pstu -> sex = 'F';
return 0;
}
int OutputStudent(struct Student stu)
{
printf("%d %c %s\n", stu.age, stu.sex, stu.name);
return 0;
}
我改成这样了 还是有错误 |
|