Enums (C)


#include <stdio.h>

/* We usually use _t for enum names */
/* By default, A would get the zero value and the others
 * would get a value incremented by one as we go through.
 * B would get the value of 1, C of 2 and so on. We can
 * set the value to start "counting" by assigning it to
 * the A.                           */

typedef enum {A = 1, B, C, D, E} alphabet_t;

int main(void)
     alphabet_t test = B;

     if(test == 2)

     return 0;

This code was developed by me, G. Samaras.

Have questions about this code? Comments? Did you find a bug? Let me know! 😀
Page created by G. (George) Samaras (DIT)


One thought on “Enums (C)

  1. Pingback: character converter

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s