要求输入输出。
#include<stdio.h>
struct STU
{
int a;
char b[20];
float c;
};
int main()
{
struct STU *p;
scanf("%d",&p->a);
scanf("%s",p->b);
scanf("%f",&p->c);
printf("no:%d\nname:%s\nscore:%.1f",p->a,p->b,p->c);
return 0;
}
你的指针p没有实际分配空间。查阅:
https://www.man7.org/linux/man-pages/man3/malloc.3.html
或者实在不熟悉指针的话,就别用指针。你这个代码我是没看出为啥要用指针。