Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

7
Enumerated data types and integer constants
Post Body

I'm working through Kochan's "Programming in C", and in the section on enumerated data types it says that the "C compiler actually treats enumeration identifiers as integer constrants", which I thought made sense until I went to compile the example program:

`#include <stdio.h>

int main (void)

{

enum month { january = 1, february, march, april, may, june, july, august, september, october, november, december };

enum month a_month;

int days;

printf ("Enter month number: ");

scanf ("%i", &a_month);

...`

GCC gave me the following error:

14.1.c: In function โ€˜mainโ€™:

14.1.c:13:18: warning: format โ€˜%iโ€™ expects argument of type โ€˜int *โ€™, but argument 2 has type โ€˜enum month *โ€™ [-Wformat=]

13 | scanf ("%i", &a_month);

| ~^ ~~~~~~~~

| | |

| | enum month *

| int *

This is how it's written in the book and it makes sense to me that this should work, what am I not understanding?

Author
Account Strength
40%
Account Age
3 months
Verified Email
Yes
Verified Flair
No
Total Karma
175
Link Karma
77
Comment Karma
98
Profile updated: 2 days ago
Posts updated: 15 hours ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 months ago