枚举C中的“未知类型名称”

时间:2019-09-15 17:23:16

标签: c

它说未知类型名称为“ week”。 在第三行显示错误。

这是我的代码:

#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;
}

1 个答案:

答案 0 :(得分:5)

正确的类型名称应为<body> <p>Some paragraph text</p> <h1>some heading 1 text</h1> <h2>some heading 2 text</h2> <a href="#" id="size-12">12</a> <script> document.getElementById('size-12').onclick = (function(size){ document.body.style.fontSize = size + 'px'; })(20); </script> </body> ,而不只是enum week

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; } ,则可以使用week将类型typedef定义为enum week

week