{
input_save(myfile, info, i)
printf("Continue? (type 'quit'戚岁戚雀租 to stop): ")
scanf("高陵%s", &ch) //这里出错 应该是 scanf("%s", ch)
getchar()//加上这个 去掉换行 或者getch()或者fflush(stdin)
if ( (x = strcmp (ch , quit)) == 0 )
{
break
}
else
{
continue
}
}
使用break语句往往跟if配合使用,在循环体里有特殊情况时可以退出循环。
例:
intmain()
{
inti
intscore//成绩
printf("输入10个成绩:\n")
for(i=0i<10i++)
{
scanf("%d",&score)
if(score<0||score>100)
{
printf("请输入合法的成绩。\n")
break
}
}
printf("循环下面的代码\n")
}
扩展资料
C语言循环类型
1、while循环当给定条件为真时,重复语句或语句组。它会在执行循环主体之前测试罩团灶条件。
2、for循环多次执行一个语句序列,简化管理循环变量的代码。
3、do...while循环除了它是在循环主体结尾测试条件外,其他与while语句类似。
4、嵌套循环您可以在while、for或do..while循环内使用一个或宏或物扮多个循环。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)