Thread: Array of structure: Structure members are enum varaibles

  1. #1
    Registered User
    Join Date
    Jun 2018

    Array of structure: Structure members are enum varaibles

    #include <stdio.h>
    typedef enum {
       GREEN = 0,
    typedef struct{
        COLOR color;
    int main()
        COLORS c;
        c.color = 0;
    How this syntax works??

    how assigning value to color changes enum

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Err... that's how enums work, although you should use GREEN instead of 0 since that's why you declared the enum in the first place.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 03-27-2017, 02:06 AM
  2. Accessing structure members
    By mc088 in forum C Programming
    Replies: 1
    Last Post: 01-26-2017, 10:42 PM
  3. How to find number of structure members in a given structure?
    By bhaskarReddy in forum C Programming
    Replies: 4
    Last Post: 01-16-2012, 05:37 AM
  4. How do I point to structure members?
    By RaisinToe in forum C++ Programming
    Replies: 2
    Last Post: 03-07-2009, 11:34 PM
  5. structure members outside main
    By threahdead in forum C Programming
    Replies: 5
    Last Post: 03-09-2003, 07:34 AM

Tags for this Thread