关于文件的问题
怎么修改已存在的文件
回复 2楼 zhoumh91
修改,不是追加,我想把其中已存在的一项修改一下
typedef struct book_ifo{ int num; char writer[CHAR]; char name[CHAR]; double price; struct book_ifo *next; }BOOK; BOOK *store(BOOK *head) //存储 { FILE *fp; BOOK *ptr, *p; p = head; if((fp = fopen("bookinfo.txt","w")) == NULL){ printf("File open error!\n"); exit(0); } for(ptr = head;ptr;ptr = ptr->next) fprintf(fp,"%d %s %s %6.2lf\n",ptr->num,ptr->writer,ptr->name,ptr->price); if(fclose(fp)){ printf("Can not close the file!\n"); exit(0); } return head; }