Table Of Contents
Previous Section Next Section

Program 8: Mad Character

The novice programmer decided to check out how to use if statements with char variables. The following program is simple, obvious, and wrong!

  1 /************************************************
  2  * Check the flag.                              *
  3  ************************************************/
  4 #include <iostream>
  5
  6 int main()
  7 {
  8     char ch;    // The flag
  9
 10     ch = 0xFF;  // Set the flag
 11
 12     // Check the flag
 13     if (ch == 0xFF)
 14         std::cout << "Success\n";
 15     else
 16         std::cout << "Fails\n"; 
 17
 18     return (0);
 19 }

(Next Hint 131. Answer 8.)

Table Of Contents
Previous Section Next Section