#include<stdio.h>
#include<string.h>
struct date
{
int year;
int month;
int day;
};
struct infor
{
char name[6];
char sex[4];
float high;
float weight;
struct date timeofenter;
int photonumber;
};
typedef struct infor in;
main(void)
{
in qx;
in *p=&qx;
strcpy(qx.name,"hjx");
strcpy(qx.sex,"man");
qx.high=166;
qx.weight=66;
qx.timeofenter.year=2007;
qx.timeofenter.month=9;
qx.timeofenter.day=1;
printf("%s",p->name);
printf("%s",p->sex);
printf("%d",p->high);
printf("%d",p->weight);
printf("%d",p->timeofenter.year);
printf("%d",p->timeofenter.month);
printf("%d",p->timeofenter.day);
}
主要問題:給name和sex賦值要用strcpy,給month賦值不能用09,因為0開頭編譯器默認是8進制數,看看還有什麽問題嗎