Using true and false in C

后端 未结 15 1906
情书的邮戳
情书的邮戳 2020-12-01 01:52

As far as I can see there are 3 ways to use booleans in c

  1. with the bool type, from then using true and false
  2. defining using preprocessor #defin
15条回答
  •  盖世英雄少女心
    2020-12-01 02:38

    I don't know you specific situation. Back when I was writing C programs, we have always used #2.

    #define FALSE = 0
    #define TRUE = !FALSE
    

    This might be otherwise under alien platform to DOS or Intel-based processors. But I used to use both C and ASM together writing graphic libraries and graphical IDE. I was a true fan of Micheal Abrash and was intending to learn about texture mapping and so. Anyway! That's not the subject of the question here!

    This was the most commonly used form to define boolean values in C, as this headerfile stdbool.h did not exist then.

提交回复
热议问题