循环问题!!
while(1){
printf("\nPlease enter the car\'s id you want to modify:");
scanf("%ld",&m);
switch(a=(array1[0].id<=m&&m<=array1[t-1].id))
{
case 0:printf("\nError input!\n");break;
case 1:d=search(m,array1);
strcpy(z,array1[d].name);
printf("\n\tPlease enter the name you want:\n");
scanf("%s",array1[d].name);
if(strcmp(z,array1[d].name)==0)
printf("\nFail!");
else
printf("\nSuccessful!");
break;
}
printf("\n\tPress \'Q\' to quit!\n");
s=getchar();
if(s=='q'||s=='Q')
break;
}
这是函数的一部分,为什么这里
printf("\n\tPress \'Q\' to quit!\n");
s=getchar();
if(s=='q'||s=='Q')
break;
不能实现,运行后跳过了s=getchar()之后的语句。
----------------解决方案--------------------------------------------------------
经再次研究,这里
printf("\n\tPress \'Q\' to quit!\n");
s=getchar();
if(s=='q'||s=='Q')
将s改成字符串却可以,又是什么原因呢?
printf("\n\tPress \'Q\' to quit!\n");
scanf("%s",s);
if(strcmp(s,"q")==0||strcmp(s,"Q")==0)
.
.
----------------解决方案--------------------------------------------------------