【发布时间】:2017-05-04 18:15:51
【问题描述】:
我在尝试输入 I/O 文件的代码中有此功能,但我似乎无法做到。
void show_list(int whyeven[stuff], char *hatred[stuff])
{
for (int g = 0; g < stuff - 1; g++)
{
if (whyeven[g] < 10 || whyeven[g] == 0)
{
printf("%s - %d (*) you should buy more of this stuff\n\n",hatred[g], whyeven[g]);
}
else if (whyeven[g] > 10)
{
printf("%s - %d\n\n", hatred[g], whyeven[g]);
}
}
}
int main()
{
show_list(moarstuff, items);
return 0;
}
【问题讨论】:
-
我们不知道它应该做什么以及它在做什么(和没有做什么)。请说清楚。另外,请提供minimal reproducible example
-
为什么要测试
whyeven[g] < 10 || whyeven[g] == 0?第二个包含在第一个中。此外,您正在测试whyeven[g] < 10和稍后的whyeven[g] > 10。whyeven[g] == 10的时候呢? -
还有一点,尽管您认为自己是,但您并没有向您的函数发送
stuff。