Trailing comma with enumerated type in C

Trailing comma with enumerated type in C

With the C99 version of C, it is legal to use trailing comma in enumerated type  in C

The advantage of adding a trailing comma to enumerated type is that it makes it easier to modify lines

As you can see, we can add a constant to the end of an enumeration data type without changing the existing line of code

#include <stdio.h>
#include <stdlib.h>
enum weak{mon=1, tue=2, wed=3, thur=4,fri=5, sat=6, sun,};
int main()
{
    enum weak day;
    day=sun;
    printf("%d",day);
    return 0;
}

Output

7

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.