Thread: Any help with bool and float

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    1,644
    If you want to print the value of a bool you can either print it as an int where it will print as 0 for false and 1 for true, or you can print it as a string.
    Code:
    // as int
    printf("bool: %d\n", (int)bool_value);
     
    // as string
    printf("bool: %s\n", bool_value ? "true" : "false");
    A little inaccuracy saves tons of explanation. - H.H. Munro

  2. #2
    Registered User
    Join Date
    Apr 2020
    Posts
    2
    As a string...Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 09-23-2018, 04:17 PM
  2. Replies: 5
    Last Post: 03-11-2014, 02:43 PM
  3. BOOL bool ? unresolved external symbol
    By xwielder in forum C Programming
    Replies: 6
    Last Post: 05-20-2008, 08:39 AM
  4. How get bool's from std::vector<bool>
    By 6tr6tr in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2008, 05:24 AM
  5. Interesting: bool != BOOL
    By lightatdawn in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 01-09-2002, 11:09 AM

Tags for this Thread