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