#include
#include
struct Student
{
int age;
char sex;
char name[100];
};//此处的分号是不能省略的
void InputStudent(struct Student *); //函数声明
void OutputStudent(struct Student *);//函数声明,这也错了,声明应该和调用定义参数类型保持一致,都是结构体指针类型
int main(void)
{
struct Student st; //定义结构体变量 15行
InputStudent(&st); //对结构体变量输入
OutputStudent(&st); //对结构体变量输出
return 0;
}
void OutputStudent(struct Student *pst)
{
printf("%d %c %s\n", pst->age, pst->sex , pst->name);//这里错了,注意输出顺序
}
void InputStudent(struct Student * pst)//pst只占用4个字节
{
(* pst).age = 22;
strcpy(pst->name,"张三");//strcpy是在 #include 里面的一个函数,未做讲解
(* pst).sex = 'F';
}