面试题答案
一键面试#include <stdio.h>
// 定义结构体
struct Student {
char name[50];
int age;
float score;
};
// 定义打印学生信息的函数
void printStudent(struct Student *student) {
printf("Name: %s\n", student->name);
printf("Age: %d\n", student->age);
printf("Score: %.2f\n", student->score);
}
int main() {
// 创建结构体变量
struct Student student1 = {"Alice", 20, 85.5f};
// 调用函数打印学生信息
printStudent(&student1);
return 0;
}