Ask coding questions

← Back to all posts
Function data type mismatch
imaddmattgaming (0)

If I delcare a prototype for a function as so:
void func(int&, int, int[], int*);

Then I declare and int but populate it as an array:
int x3 = {0};
What happens to the x3 variable that is passed into the second parameter?

Vandesm14 (1665)

Can you provide a link to your repl?

Vandesm14 (1665)

@imaddmattgaming The x3 variable is an array, so when it is passed into the function (when the parameter is supposed to be an integer), it returns an error.

Please mark this as answered if I helped your problem 👍

imaddmattgaming (0)

@Vandesm14 So then if for a question they wanted the outputs, It would be none? Just a compiler error will occur?

On the memo for the test where this question originated, the output is said to be 3 9 7 0 3

Vandesm14 (1665)

@imaddmattgaming Yes, it should be an error, unless they want you to pass the array to the correct array parameter. Otherwise, you should be fine!