It says unknown type name 'week'.. Error showing on 3rd line.
Here is my Code:
#include <stdio.h>
enum week{ sunday, monday, tuesday, wednesday, thursday, friday, saturday };
void lecture_unit(week day)
{
if (day == friday) printf("COS10008\n");
if (day == monday) printf("Maths\n");
if (day == sunday) printf("Holiday\n");
}
int main()
{
week today;
today = sunday;
lecture_unit(today);
printf("Day %d\n",today);
return 0;
}
The correct type name should be enum week
instead of just week
#include <stdio.h>
enum week{ sunday, monday, tuesday, wednesday, thursday, friday, saturday };
void lecture_unit(enum week day)
{
if (day == friday) printf("COS10008\n");
if (day == monday) printf("Maths\n");
if (day == sunday) printf("Holiday\n");
}
int main()
{
enum week today;
today = sunday;
lecture_unit(today);
printf("Day %d\n",today);
return 0;
}
If you prefer to use week
instead you can use typedef
to define type enum week
as week
#include <stdio.h>
enum week{ sunday, monday, tuesday, wednesday, thursday, friday, saturday };
typedef enum week week;
void lecture_unit(week day)
{
if (day == friday) printf("COS10008\n");
if (day == monday) printf("Maths\n");
if (day == sunday) printf("Holiday\n");
}
int main()
{
week today;
today = sunday;
lecture_unit(today);
printf("Day %d\n",today);
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With