C continue

2018-05-19 19:25 更新

學(xué)習(xí)C - C continue

要跳過(guò)當(dāng)前的迭代并繼續(xù)下一個(gè),請(qǐng)?jiān)谘h(huán)體中使用continue語(yǔ)句。

continue;

例子


#include <stdio.h>
int main(void){
    int guess = 1;
    char response;

    printf("is your number %d?\n", guess);
    while ((response = getchar()) != "y")     /* get response */
    {
        if (response == "n")
            printf("Well, then, is it %d?\n", ++guess);
        else
            printf("Sorry, I understand only y or n.\n");
        while (getchar() != "\n")
            continue;                 /* skip rest of input line */
    }
   
    return 0;
}

上面的代碼生成以下結(jié)果。



以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)