Problems about the bool type in Linux C

Source: Internet
Author: User

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 };

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.