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;
}
The function body is what is giving me error messages. The function is meant to round an array index to the nearest hundredth. I separately passed both the index variable and the array to the function. Here is the error message:
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
My first guess was that I needed to include empty brackets after the baln in the parameter field, but that didn’t help. Any ideas?
You had it right; you do need to include empty brackets after
balnin the parameter list, like so:Here’s a full demo.