注册 登录
编程论坛 C语言论坛

关于continue;的作用范围

蹴鞠者 发布于 2017-05-24 11:58, 3459 次点击
程序代码:
    while(count < MAXBKS && gets(library[count].title) != NULL && library[count].title[0] != '\n')
    {
        printf("Now enter the author.\n");
        gets(library[count].author);
        printf("Now enter the value.\n");
        scanf("%f",&library[count++].value);
        while(getchar() != '\n')
            continue;           //清空输入行
        if(count < MAXBKS)
            printf("Enter the next title.\n");

    }

这个continue;在这的作用是什么
8 回复
#2
renkejun19422017-05-24 12:03
当前循环。

PS,你到底要问什么,是问continue的作用域,还是问它的作用?

[此贴子已经被作者于2017-5-24 12:05编辑过]

#3
Emotiona2017-05-24 12:30
运用是返回到while循环。配合上面while循环,达到清空输入流的目的
#4
蹴鞠者2017-05-24 13:46
回复 2楼 renkejun1942
作用域
#5
蹴鞠者2017-05-24 14:39
回复 3楼 Emotiona
能详细说一下吗
#6
renkejun19422017-05-24 18:14
while(getchar() != '\n')
            continue;//这句continue没有半毛钱作用,在这里,可以直接删掉。留一个分号在哪里就可以了。
#7
Emotiona2017-05-24 18:56
回复 5楼 蹴鞠者
作用域就在while, 不过要不要都一样, 等于是废话。
#8
蹴鞠者2017-05-25 11:36
回复 7楼 Emotiona
有两个while,是外层的还是内层的
#9
Emotiona2017-05-25 11:47
回复 8楼 蹴鞠者
while(getchar() != '\n')
            continue;   


循环没括号,表明只执行循环下的一句话
1