Use of Blackhorse programmers 06-bool

Source: Internet
Author: User

--- Java training, Android training, IOS training, and. Net training. We look forward to communicating with you! ---

Use of the bool type (no bool type in C language)

1. bool type nature

The essence of the bool type is actually an integer. Its two values yes and no can be expressed by 1 and 0 respectively.

MACRO: Yes indicates non-zero, no indicates zero;

Microscopic: Yes indicates 1, no indicates 0.

Typedef signed Char bool

2. There are two bool types: yes and no.

# Define Yes (bool) 1

# Define no (bool) 0

3. bool output (as an integer)

1 nslog (@ "% d", yes, no );

4. Write the following code:

 

1 # import <Foundation/Foundation. h> 2 // Return Value Type of bool. The function returns a NO 3 bool test (bool mybool) 4 {5 return no; 6} 7 8 int main (INT argc, const char * argv []) 9 {10 bool B = yes; 11 bool b2 = no; 12 bool B3 = 1; // Yes 13 bool B4 = 0; // No14 15 nslog (@ "B = % d", B); // The result is B = 116 nslog (@ "b2 = % d", B2 ); // The result is b2 = 017 nslog (@ "B3 = % d", B3); // The result is B3 = 118 nslog (@ "B4 = % d", b4 ); // The result is B4 = 019 nslog (@ "% d", test (yes); // The result is 020 return 0; 21}

 

This section focuses on:

1. the bool type is actually an integer. Its two values yes and no can be expressed by 1 and 0 respectively.

Typedef signed Char bool

2. There are two bool types: yes and no.

3. bool output (as an integer ).

    

 

 

 

 

Use of Blackhorse programmers 06-bool

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.