我是一名初级程序员(大约一周),我的简单程序不断崩溃。我做错了什么?在我输入小时数之前它就崩溃了。请帮忙。
#include <stdio.h>
#include <stdlib.h>
int hours;
float wage;
float total[2];
int main()
{
printf("How many hours have you worked this week?\n");
fgets(hours, sizeof(hours), stdin);
sscanf(hours,"%d", &wage);
if (hours < 40)
wage = 8.5;
total[0] = hours * wage;
printf("You will earn %d dollars", total[0]);
if (hours >= 40)
wage = 12.75;
total[1] = hours * wage;
printf("You will earn %d dollars", total[1]);
return 0;
}