Ask coding questions

← Back to all posts
Warning popping up
patricknascime2 (0)

I don't understand why this warning is popping up.

Well, seems like this warning is coming from an array that has two elements.

Answered by vedprad1 (860) [earned 5 cycles]
View Answer
vedprad1 (860)

The array num only has 1 element, and you are asking it to create another one, which it cannot do.

To fix this, change line 5 from this:

int num[1], maiorNumero = 0, soma;

to this:

int num[2] = {0, 0};
int maiorNumero = soma;

However, even this has a problem. At that point, you have not defined soma yet. Thus, you cannot set maiorNumero to the value of soma, because soma doesn't exist.

If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!

patricknascime2 (0)

@vedprad1 Thank you for the answer, I make some changes in the code and now is working!