0
Good evening, someone can tell me why this message appears in the program in c language, and if it has how to solve? Run-Time Check Failure #2 - Stack Around the variable 'note' was corrupted. Float ta note[3] why vector starts counting 0 then it would have to be right with 4 numbers.
#include<stdio.h>
#include<stdlib.h>
main() {
float nota[3];
nota[0] = 8.5;
nota[1] = 7.5;
nota[2] = 10;
nota[3] = 10;
printf("A primeira nota = %.2f\n", nota[0]);
printf("A segunda nota = %.2f\n", nota[1]);
printf("A terceira nota = %.2f\n", nota[2]);
printf("A quarta nota = %.2f\n", nota[3]);
system("pause");
return 0;
}
"'Cause that vector starts with a zero so you’d have to be right with four numbers." In fact you indicate that it will have 3 indexes, as the first index is 0, it ends in note[2]
– Barbetta
If you want to have 4 notes you have to declare as
float nota[4];
. The number in the declaration is the size and not the last position.– Isac