面试题答案
一键面试#include <stdio.h>
// 定义结构体
struct student {
char name[20];
int age;
float score;
};
// 定义打印学生信息的函数
void printStudentInfo(struct student *stu) {
printf("Name: %s\n", stu->name);
printf("Age: %d\n", stu->age);
printf("Score: %.2f\n", stu->score);
}
你可以在main
函数中这样调用这个函数:
int main() {
struct student stu = {"Alice", 20, 85.5};
printStudentInfo(&stu);
return 0;
}