我一定是疯了。这非常简单,所以我显然忽略了一些东西:
这是我的代码:
int salesarray[20];
scanf("%d",&sales_input);
printf("sales_input is %d",sales_input);
salesarray[i] = sales_input;
printf("salesValue is %d",i,salesarray[i]);
这是我将要看到的:
sales_input 为 2salesValue 为 1
谁能解释为什么我的数组没有正确更新? salesValue 应该更改为值 2。或者我在这里读错了...
最佳答案
解决这个问题:
printf("salesValue is %d",i,salesarray[i]);
不应该吗?
printf("salesValue is %d", salesarray[i]);
关于c - 在 C 中向数组写入/读取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1660773/