面试题答案
一键面试#include <stdio.h>
int main() {
struct Student {
char name[20];
int age;
float score;
};
struct Student student;
struct Student *ptr = &student;
// 使用结构体指针初始化
sprintf(ptr->name, "Tom");
ptr->age = 20;
ptr->score = 85.5f;
// 输出结构体变量信息
printf("Name: %s\n", ptr->name);
printf("Age: %d\n", ptr->age);
printf("Score: %.2f\n", ptr->score);
return 0;
}