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.
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?
Subreddit
Post Details
- Posted
- 3 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/C_Programmi...