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

后端 未结 12 843
予麋鹿
予麋鹿 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:59

    Well, not really but it depends on your architecture.

    if (dosomething()) { ; }
    

    The above is going to constantly be pushing and popping from your local stack, which has a memory overhead. Also, you will also be flushing your processors' pipelines with noop operations.

提交回复
热议问题