Is if(TRUE) a good idea in C?

后端 未结 17 3508
忘了有多久
忘了有多久 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:38

    You can remove the

    if(TRUE)
    

    and just leave the braces, which by themselves define a new syntactic block - a compound statement.

    This is definitely cleaner than the false if you had before, but you might still like to ask yourself why you want to create a new block - would it be better to define a subroutine?

提交回复
热议问题