Error help

On line 5 I am receiving the error "assignment of function void sum(int*). Could someone explain why that is the case?

1
2
3
4
5
6
7
8
9
 void sum(int testArray[])
{
    for(int j = 0; j < 100; j++)
    {
        sum = sum + testArray[j];
        cout << sum;
        return;
    }
}
sum is the name of your function. You can't use that for a local variable as well.

In addition, you didn't initialise it (to zero) before you started adding to it - but that's a different sort of error.

And your loop won't run very much if you return from the function within the first pass through it.
Last edited on
Topic archived. No new replies allowed.