我在循环中检查carNo,所以我请求用户输入。 但字符串"输入carBrand和carPrice:"在控制台中循环。不明白为什么。
//manually fill records
filePtr = fopen("CARDATABASE.dat", "rb+");
printf("Enter car no: ");
scanf("%d", &blankEntry.carNo);
while (blankEntry.carNo!=0){
printf("Enter carBrand and carPrice: \n");
fscanf(stdin, "%d %s %f", &blankEntry.carNo, blankEntry.carBrand, &blankEntry.carPrice);
fseek(filePtr, (blankEntry.carNo - 1)*sizeof(struct carData), SEEK_SET);
fwrite(&blankEntry, sizeof(struct carData), 1, filePtr);
printf("Enter car no: ");
scanf("%d",&blankEntry.carNo);
}