user3007186
user3007186

Reputation: 9

Invalid conversion from int to int c++?

I declared this function :

int dice(int roll[8]) {
blah blah
return (score);

And called it in int main:

newScore = score(roll[8]);

I am getting an invalid conversion from int to int error. What am I doing wrong? The error is on the line where I call it.

Upvotes: 1

Views: 2555

Answers (1)

None
None

Reputation: 2595

int dice(int roll[8]);

int roll[8];
int newScore = dice(roll);

This is how arrays are "passed" as arguments.

What happens is dice() receives an int* (which may happen to not point to an array of size 8!) and when using roll as an argument, it "decays" into a pointer to its first element.

Upvotes: 3

Related Questions