Is if(TRUE) a good idea in C?

后端 未结 17 3455
忘了有多久
忘了有多久 2021-02-19 01:19

In the C programming language, it is my understanding that variables can only be defined at the beginning of a code block, and the variable will have the scope of the block it w

17条回答
  •  遇见更好的自我
    2021-02-19 01:20

    Since you can just make the scope block without the if, that's a better idea.

    void foo() {
         ... Do some stuff ...
         {
             char a;
             int b;
             ... Do some more stuff ...
         }
         ... Do even more stuff ...
    }
    

提交回复
热议问题