C Don';我不知道为什么';m获取无效类型的错误信息';int[int]';数组下标
我需要帮助。我在学习c语言编程。我理解错误消息,但不确定如何修复它。我试着把“temp”做成一个浮点数或一个字符串。它也不起作用C Don';我不知道为什么';m获取无效类型的错误信息';int[int]';数组下标,c,C,我需要帮助。我在学习c语言编程。我理解错误消息,但不确定如何修复它。我试着把“temp”做成一个浮点数或一个字符串。它也不起作用 #include <stdio.h> #define TEMPS 12 int main() { int temperature[TEMPS]; int counter; temperature[0] = 70; temperature[1] = 60; temperature[2] = 20;
#include <stdio.h>
#define TEMPS 12
int main()
{
int temperature[TEMPS];
int counter;
temperature[0] = 70;
temperature[1] = 60;
temperature[2] = 20;
temperature[3] = 80;
temperature[4] = 90;
temperature[5] = 72;
temperature[6] = 89;
temperature[7] = 40;
temperature[8] = 88;
temperature[9] = 72;
temperature[10] = 78;
temperature[11] = 91;
for (counter=0; counter<TEMPS; counter++) {
printf("Daily the average temperature in month %d and press ENTER %d\n",
TEMPS[counter],
temperature[counter]);
}
printf("The temperatures over the past 12 months are\n");
for (counter=0; counter<12; counter++) {
printf(" %d ", temperature[counter]);
}
return 0;
}
#包括
#定义临时工12
int main()
{
内部温度[温度];
整数计数器;
温度[0]=70;
温度[1]=60;
温度[2]=20;
温度[3]=80;
温度[4]=90;
温度[5]=72;
温度[6]=89;
温度[7]=40;
温度[8]=88;
温度[9]=72;
温度[10]=78;
温度[11]=91;
用于(计数器=0;计数器
TEMPS不是数组,而是整数
printf("Daily the average temperature in month %d and press ENTER %d \n", counter, temperature[counter]);
我还没有详细了解您想要实现的目标,但我觉得上面这一行更好。TEMPS[counter]
?即12[counter]
。看起来像是打字错误。。。
printf("Daily the average temperature in month %d and press ENTER %d \n", counter, temperature[counter]);