Thread: Working with boolean...

  1. #1
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438

    Working with boolean...

    Seems odd the extra hoops I have to jump through to use boolean. Can anybody help me figure out what's wrong here?

    Code:
    #include <stdio.h>
    #define TRUE 1
    #define FALSE 0
    typedef int boolean;
    
    struct student
    {
            int cnt;
    };
    
    main()
    {
            boolean continue = TRUE;
            int option = 0;
    
            do
            {
                    printf("Select an option:\n\t1. View All Students\n");
                    scanf("%d", &option);
                    printf("Option: %d", option);
            } while (continue == TRUE);
    
    /* Ignore everything below this */
            struct student *s;
            s->cnt = 10;
            printf("%d\n", s->cnt);
    }
    I'm getting "parse error before 'continue'" twice and I'm not really sure why...

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    'continue' is a reserved keyword in C.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    97
    BTW, isn't that kind of an infinite loop? Since you never change your value for the variable of the while, "continue" then the loop will keep going forever. I'm just not sure because I woke up 10 minutes ago and its 7:41AM here

  4. #4
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438
    Originally posted by Sebastiani
    'continue' is a reserved keyword in C.
    Ah, I should have known...

  5. #5
    Registered User Sargnagel's Avatar
    Join Date
    Aug 2002
    Posts
    166
    The ANSI C99 standard already provides a boolean data type.

    #include <stdbool.h>

    bool/true/false

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Novice needs help
    By ghaasemi in forum C++ Programming
    Replies: 9
    Last Post: 05-30-2009, 08:20 AM
  2. Casting boolean as string
    By doofusboy in forum C Programming
    Replies: 11
    Last Post: 11-10-2005, 12:24 PM
  3. Replies: 3
    Last Post: 09-12-2005, 09:08 AM
  4. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM