输出必须是
Student Number: 93745;
Grade Point Ave:2.9;
Sex (M or F):'M';
但我无法获得所需的输出,请指出代码中的错误并帮助解决它,谢谢!
#include <stdio.h>
struct student {
int num;
double gpa;
char sex;
};
void printstudent(struct student *p); /* prototype */
int main() {
/* allocate storage and initialize it */
struct student joe,*kim;
kim=&joe;
kim->num = 93745;
kim->gpa = 2.9;
kim->sex = 'M';
printstudent(joe);
}
void printstudent(struct student *p) {
printf("Student Number: %i\n", p->num);
printf(" Grade Point Ave: %0.2f\n",p->gpa);
printf(" Sex (M or F): %c\n\n", p->sex);
}