c语言bool类型函数错误,显示异常说bool为不明确类型~个人怀疑编译器的有关问题~求指教~...

显示错误说bool为不明确类型~~个人怀疑编译器的问题~~求指教~~

#include

#include

#include

#include

#define NAME_MAX 20

struct

{

char *filename;

FILE *pfile;

}global={"E:\\myfile.bin",NULL};

struct Date

{

int day;

int month;

int year;

};

typedef struct family

{

struct Date dob;

char name[NAME_MAX];

char pa_name[NAME_MAX];

char ma_name[NAME_MAX];

}Family;

bool get_person(Family *pfamily);

void getname(char *name);

void show_person_data(void);

void get_parent_dob(Family *pfamily);

int main(void)

{

Family *member;

if(!(global.pfile=fopen(global.filename,"wb")))

{

printf("\nUnable to open %s for writing.\n",global.filename);

exit(1);

}

while(get_person(member))

fwrite(member,sizeof(member),1,global.pfile);

fclose(global.pfile);

show_person_data();

if(remove(global.filename))

printf("\nUnable to delete %s.\n",global.filename);

else

printf("\nDeleted %s OK.\n",global.filename);

return 0;

}

bool get_person(Family *temp)

{

static char more='\0';

printf("\nDo you want to enter details of a%s person(Y or N)?",

more!='\0'?"nother":"");

scanf(" %c",&more);

if(tolower(more)=='n')

return false;

printf("\nEnter the name of the person:");

getname(temp->name);

printf("\nEnter %s's date of birth (day month year);",temp->name);

scanf("%d %d %d",&temp->dob.day,&temp->dob.month,&temp->dob.year);

printf("\nWho is %s's father?",temp->name);

getname(temp->pa_name);

printf("\nWho is %s's mother?",temp->name);

getname(temp->ma_name);

return true;

}

void getname(char *name)

{

fflush(stdin);

fgets(name,NAME_MAX,stdin);

int len=strlen(name);

if(name[len-1]=='\n')

name[len-1]='\0';

}

void show_person_data(void)

{

Family member;

fpos_t current=0;

if(!(global.pfile=fopen(global.filename,"rb")))

{

printf("\nUnable to open %s for reading.\n",global.filename);

exit(1);

}

while(fread(&member,sizeof member,1,global.pfile))

{

fgetpos(global.pfile,&current);

printf("\n\n%s's father is %s,and mother is %s",

member.name,member.pa_name,member.ma_name);

get_parent_dob(&member);

fsetpos(global.pfile,&current);

}

fclose(global.pfile);

}

void get_parent_dob(Family *pmember)

{

Family relative;

int num_found=0;

rewind(global.pfile);

while(fread(&relative,sizeof(Family),1,global.pfile))

{

if(strcmp(pmember->pa_name,relative.name)==0)

{

printf("\nPa was born on %d/%d/%d",

relative.dob.day,relative.dob.month,relative.dob.year);

if(++num_found==2)

return;

}

else

if(strcmp(pmember->ma_name,relative.name)==0)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值