I have a question regarding array, for example, if I have 2 arrays of size 9 and to print the values of both is normal the input 9 get the value 0 of the next array?, this is another test, I know the maximum is 8?
Code sample:
struct stType {
type[9];
}select;
strcut vrType {
type[9];
}variable;
void st_type(int type, int value) {
int i;
uint32 type_select = select_type(type);
ST_TYPE(i, type_select) {
select->type[i] += value;
}
}
void vr_type(int type, int value) {
int i;
uint32 type_select = variable_type(type);
VR_TYPE(i, type_select) {
variable->type[i] += value;
}
}
int main() {
st_type(0, 50); // define valor 50 para array select->type[0]
vr_type(0, 60); // define valor 60 para array variable->type[0]
for (i = 0; i < 10; i++)
printf("[ST Debug %d] Value: %d\n", i, select->type[i]);
printf("\n");
for (i = 0; i < 10; i++)
printf("[VR Debug %d] Value: %d\n", i, variable->type[i]);
}
Output:
[ST Debug 0] Value: 50
[ST Debug 1] Value: 0
[ST Debug 2] Value: 0
[ST Debug 3] Value: 0
[ST Debug 4] Value: 0
[ST Debug 5] Value: 0
[ST Debug 6] Value: 0
[ST Debug 7] Value: 0
[ST Debug 8] Value: 0
[ST Debug 9] Value: 60 // posição 9 puxa o 0 de vr
[VR Debug 0] Value: 60
[VR Debug 1] Value: 0
[VR Debug 2] Value: 0
[VR Debug 3] Value: 0
[VR Debug 4] Value: 0
[VR Debug 5] Value: 0
[VR Debug 6] Value: 0
[VR Debug 7] Value: 0
[VR Debug 8] Value: 0
[VR Debug 9] Value: 0