1.结构体的定义:
struct Student
{
int age;
float score;
char sex;
};
# include <stdio.h>
# include <string.h>
struct student
{
int age;
char sex;
char name[100];
};
void InputStudent(struct student * pstu) //对结构体变量输入必须发送st的地址
{
(*pstu).age = 10;
strcpy(pstu->name, "zhangsan");
pstu->sex = 'F';
}
void OutputStudent(struct student ss) //对结构体变量输出,可以发送st的地址,也可以发送st的内容(发送地址耗用内存少,速度快)。
{
printf("%d %c %s\n", ss.age, ss.sex, ss.name);
}
int main(void)
{
struct student st;
InputStudent (& st);
OutputStudent (st);
return 0;
}