exit(0);
程序代码:
#include <stdio.h> int main(void) { struct person { char name[20]; char sex; int age; float height; }person1; FILE *fp; int i; char fname[20]; printf("please input file name:\n"); scanf("%s",fname); printf("please input three person's name,sex,age and height:\n"); if ((fp = fopen(fname,"wb")) == NULL) { printf("cannot open this file!\n"); return 0; } for (i=1 ;i<4 ;i++) { scanf("%s %c%d%f",person1.name,&person1.sex,&person1.age,&person1.height); if ((fwrite(&person1, sizeof(person1), 1, fp)) != 1) { printf("write error!\n"); return 0; } } fclose(fp); printf("the content of the file is:\nNAME\t\tsex\tage\theight\n"); if ((fp = fopen(fname,"wb")) == NULL) { printf("cannot open this file!\n"); return 0; } for (i=1; i<4; i++) { if ((fread(&person1, sizeof(person1), 1, fp)) == 1) { printf("%-16s%-8c%-8d%-10.2f",person1.name,person1.sex,person1.age,person1.height); } } fclose(fp); return 0; }这个程序从书上弄来的,exit(0);语句编译的时候提示函数未申明而无法编译,而书上也没有申明,这是为什么呢?