c - 这个数组错误是什么意思?

标签 c arrays

void arrayRound(int id, double baln)
{
    baln[id] = (baln[id]*100) + 0.5;
    int temp = (int) baln[id];
    baln[id] = (double) temp;
    baln[id] = baln[id] / 100;
}

函数体给我错误信息。该函数旨在将数组索引四舍五入到最接近的百分之一。我分别将索引变量和数组传递给函数。这是错误消息:

Fxns.c:70: error: subscripted value is neither array nor pointer
Fxns.c:70: error: subscripted value is neither array nor pointer
Fxns.c:71: error: subscripted value is neither array nor pointer
Fxns.c:72: error: subscripted value is neither array nor pointer
Fxns.c:73: error: subscripted value is neither array nor pointer
Fxns.c:73: error: subscripted value is neither array nor pointer

我的第一个猜测是我需要在参数字段中的 baln 之后包含空括号,但这没有帮助。有什么想法吗?

最佳答案

你是对的;您确实需要在参数列表中的 baln 之后包含空括号,如下所示:

void arrayRound(int id, double baln[]);

Here's a full demo.

关于c - 这个数组错误是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9592148/

相关文章:

c - Microhttpd 服务器不想发送页面

arrays - 找到两个数组的所有可能距离

C - 在函数中将值存储在数组中

ios - Swift:按字母顺序对数组进行排序

java - 3维数组索引越界

c - C 结构体数组的实现

c - 如何利用 txt 文件中的换行符将 lcd 光标移至下一行?

c++ - C 和 C++ 代码之间的不兼容

arrays - 在 VBA 中将值 "directly"传递给数组

c - 使用fgetc逐行读取不起作用