#include"stdio.h"
//#include"reg51.h"
#define FORMAT "% d\n% s\n% f\n% f\n% f\n"
struct student
{
int num;
char name[20];
float score[3];
}stu = {12345,"Li Li",67.5,89.1,78.6};
void print(struct student *p)
{
printf("num:%d\nname:%s\nscore:%5.1f,%5.1f,%5.1f\n",
p -> num,p -> name,p -> score[0],p -> score[1],p -> score[2]);
}
void main()
{
struct student *p = &stu;
print(p);
print(&stu);
}
修改之后。VS2008可以运行,运行结果正确。
在vc++6.0 里面运行 就是78.6啊 不知道你用的什么编译器导致 是0