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
Leave a Reply