具体而言,我想介绍在开始时声明的6区不同的汽车。该程序询问我该车的哪个区域,如果输入相同,我会继续提供车辆的详细信息,如果没有,我想回到区读。我的问题是,当我正确地读了第一个地区,该计划正常工作,并返回到区读,但在第二个,不再工作。我将附上上面的代码。我需要提到的是,这是我第一次使用“继续”和“破发”声明,我认为这是主要问题。谢谢 !在do..while循环中继续并打破语句错误
#include <stdio.h>
#include <string.h>
typedef struct record {
char name[15];
int year[4];
char serial[15];
char owner[24];
char plate[12];
};
int main() {
struct record rec[100];
char search[20];
int imax=0;
int i=0,j=0;
char n;
char* district[]= {"Rahova","Giulesti","Crangasi","Militari","Pantelimon","Ferentari"};
char district_input[20];
printf("\nEnter the cars: ");
do {
printf("\nCar's number %d -> Enter district: ",i+1);
scanf("%s",district_input);
for (;j<=5;j++) {
if(strcmp(district_input,district[j])==0){
printf("\t\t ->Name of the car: ");
scanf("%s",rec[i].name);
printf("\t\t ->Release year: ");
scanf("%d",rec[i].year);
printf("\t\t ->Serial number: ");
scanf("%s",rec[i].serial);
printf("\t\t ->Number plate: ");
scanf("%s",rec[i].plate);
printf("\t\t ->Last 3 owners: ");
scanf("%s",rec[i].owner);
printf("\nAdd more? [y/n]\t");
i++;
imax++;
break;
}
continue;
}
printf("\nAdd more? [y/n]\t");
} while ((n=getche()) != 'n');
}
的'continue'在'for'循环结束已没有影响。不确定什么不明确;阅读C书中的两条语句。 – Olaf