I have been studying C Language Development in Linux over the past few days. Today, I want to write a question with a prime number ranging from 1 to 100. However, a compilation error occurs when I use the bool type to define variable B to mark whether a number is a prime number. The error message is shown as follows:
'Bool 'undeclared (first use in this function)
(Each undeclared identifier is reported only once
For each function it appears in .)
I have been searching for Google for a long time, but I still don't understand it. Later, I had to request a master. The reply is summarized below:
C language (or C ++) does not have the Boolean Type bool. Some compilers can recognize the bool type, for example, # define bool Int.
In C language, integer variables are generally used to implement the functions of Boolean variables. When a condition statement, such as if, is used for determination, if the value is 0, false is returned. If it is other conditions, true is returned.
_ Bool is the c99 standard, and TC3 certainly does not
Bool TC3 doesn't know either.
You can enumerate an Enum bool {false = 0, true =! False };