c语言求改错#include typedef struct Birthday{short year;short month;short day;}Bir;typedef struct Student{char name[10];long ID;Bir birthday;float height;float weight;}STU;STU MyClass[5];void StudyStructMem(){printf("\tsize\tAddr0\tAddr1\tAddr2\t
来源:学生作业帮助网 编辑:六六作业网 时间:2025/02/06 11:32:36
c语言求改错#include typedef struct Birthday{short year;short month;short day;}Bir;typedef struct Student{char name[10];long ID;Bir birthday;float height;float weight;}STU;STU MyClass[5];void StudyStructMem(){printf("\tsize\tAddr0\tAddr1\tAddr2\t
c语言求改错
#include
typedef struct Birthday
{
short year;
short month;
short day;
}Bir;
typedef struct Student
{
char name[10];
long ID;
Bir birthday;
float height;
float weight;
}STU;
STU MyClass[5];
void StudyStructMem()
{
printf("\tsize\tAddr0\tAddr1\tAddr2\tAddr3\tAddr4\tAddr5\n");
printf("Bithday:%d\t",sizeof(Bir));
printf("%x\t%x\t%x\t%x\n",&Bir,&Bir.year,&Bir.month,&Bir.day);
printf("Student:%d\t",sizeof(STU));
printf("%x\t%x\t%x\t%x\t%x\t%x\n",&STU,&STU.name,&STU.ID,&STU.Br,&STU.height,&STU.weight);
printf("MyClass:%d\t",sizeof(MyClass));
printf("%x\t%x\t%x\t%x\t%x\t%x\n",&MyClass,&MyClass[0],&MyClass[1],&MyClass[2],&MyClass[3],&MyClass[4]);
}
void main()
{
StudyStructMem();
}
C:\Users\IdeaPad\Desktop\Project8\eight1.c(27) :error C2275:'Bir' :illegal use of this type as an expression
C:\Users\IdeaPad\Desktop\Project8\eight1.c(9) :see declaration of 'Bir'
C:\Users\IdeaPad\Desktop\Project8\eight1.c(29) :error C2275:'STU' :illegal use of this type as an expression
C:\Users\IdeaPad\Desktop\Project8\eight1.c(18) :see declaration of 'STU'
c语言求改错#include typedef struct Birthday{short year;short month;short day;}Bir;typedef struct Student{char name[10];long ID;Bir birthday;float height;float weight;}STU;STU MyClass[5];void StudyStructMem(){printf("\tsize\tAddr0\tAddr1\tAddr2\t
#include <stdio.h>
typedef struct Birthday
{
short year;
short month;
short day;
}Bir;
typedef struct Student
{
char name[10];
long ID;
Bir birthday;
float height;
float weight;
}STU;
STU MyClass[5];
void StudyStructMem()
{
printf("\tsize\tAddr0\tAddr1\tAddr2\tAddr3\tAddr4\tAddr5\n");
printf("Bithday:%d\t",sizeof(Bir));
printf("%x\t%x\t%x\t%x\n", &Bir, &Bir.year, &Bir.month, &Bir.day);//Bir是类型 不能取地址
printf("Student:%d\t",sizeof(STU));
printf("%x\t%x\t%x\t%x\t%x\t%x\n", &STU, &STU.name, &STU.ID, &STU.Br, &STU.height, &STU.weight);//STU是类型 不能作为取地址 变量输出
printf("MyClass:%d\t",sizeof(MyClass));
printf("%x\t%x\t%x\t%x\t%x\t%x\n", &MyClass, &MyClass[0], &MyClass[1], &MyClass[2], &MyClass[3], &MyClass[4]);
}