这个小函数怎么老是错呢?求解
程序代码:
int Revise(char FileName[]) { int i = 0, j; Node book, newbook; book.m = 1; newbook.m = 1; printf("请输入想要修改的图书的登录号\n"); scanf("%ld", &newbook.Nub); FILE * fp ; fp = fopen(FileName, "r+"); while(1){ book.AuthorName[0] = '@'; fread(&book, sizeof(book), 1, fp); if(book.AuthorName[0] == '@'){ printf("Have not found! please try again !\n"); return 0; } i++; if(newbook.Nub == book.Nub){ break; } } printf("%d\n", i); FILE * fq ; fq = fopen(FileName, "r+"); if(i == 1){ printf("请输入新的登录号\n"); scanf("%ld", &newbook.Nub); printf("%ld\n", newbook.Nub); getchar(); printf("请输入新的书名\n"); gets(newbook.BookName); printf("请输入新的作者名\n"); gets(newbook.AuthorName); printf("请输入新的分类号\n"); scanf("%ld", &newbook.FLH); printf("请输入新的出版单位\n"); getchar(); gets(newbook.PubUnit); printf("请输入新的出版时间\n"); gets(newbook.PubTime); printf("请输入新的价格\n"); gets(newbook.price); fwrite(&newbook, sizeof(newbook), 1, fq); fclose(fq); printf("修改成功!!!\n"); } if(i != 1){ fseek(fq, (i-1)*sizeof(newbook)+i-1, 0); printf("请输入新的登录号\n"); scanf("%ld", &newbook.Nub); printf("%ld\n", newbook.Nub); getchar(); printf("请输入新的书名\n"); gets(newbook.BookName); printf("请输入新的作者名\n"); gets(newbook.AuthorName); printf("请输入新的分类号\n"); scanf("%ld", &newbook.FLH); printf("请输入新的出版单位\n"); getchar(); gets(newbook.PubUnit); printf("请输入新的出版时间\n"); gets(newbook.PubTime); printf("请输入新的价格\n"); gets(newbook.price); fwrite(&newbook, sizeof(newbook), 1, fq); fclose(fq); printf("修改成功!!!\n"); } } } 为什么我在修改数据块的时候,虽然成功修改了我要修改的数据块,但后面的数据块就成乱码了?求解