I am taking my first programing course in college... and I am completely lost on this assignment. I am not sure what is wrong with my current code. Any help will be appreciate it... thanks!
I keep on getting the follow error messages when I try to compile it.
test.c:3: error: syntax error before numeric constant
test.c: In function `main':
test.c:18: error: `next_day' undeclared (first use in this function)
test.c:18: error: (Each undeclared identifier is reported only once
test.c:18: error: for each function it appears in.)
test.c: In function `find_next_day':
test.c:25: error: parameter name omitted
test.c:29: error: syntax error before "day"
test.c:32: error: break statement not within loop or switch
test.c:33: error: case label not within a switch statement
....
test.c:53: error: syntax error before "return"
My code is the following:
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- enum day {sun=1, mon, tue, wed, thur, fri, sat};
- typedef enum day day;
- day find_next_day (day);
- int main(void)
- {
- day x, next_day;
- printf("\nEnter a day. ");
- scanf("%d", &x);
- find_next_day (x);
- printf ("%d", next_day);
- return 0;
- }
- day find_next_day (day)
- {
- day next_day;
- switch (day) {
- case sun:
- next_day = mon;
- break;
- case mon:
- next_day = tue;
- break;
- case tue:
- next_day = sun;
- break;
- case wed:
- next_day = thur;
- break;
- case thur:
- next_day = fri;
- break;
- case fri:
- next_day = sat;
- break;
- case sat:
- next_day = sun;
- break;
- }
- return next_day;
- }