Is using a while block to do nothing a bad thing?

后端 未结 12 1052
予麋鹿
予麋鹿 2021-02-01 03:29

I\'m currently working through the excercises in \'The C Programming Language\'. Here\'s one of my solutions:

int c;

while ((c=getchar()) != EOF) {

if (c == \         


        
12条回答
  •  忘掉有多难
    2021-02-01 03:56

    I don't think the procedure is, but your formatting is pretty weird. There's nothing wrong with:

    /* Eat spaces */
    while ((c = getchar()) == ' ');
    

    (that is, indicate there's intentionally not a body)

提交回复
热议问题