0
In the code I created a array of the kind Pessoa
containing only 2, but when it starts to iterate on the for loop and accesses index 2 and 3 the condigo continues without generating error at compile or run time. This behavior is normal?
#include <stdio.h>
#include <windows.h>
typedef struct{
int num;
}Pessoa;
Pessoa pessoa[2];
int main (int argc, char *argv[])
{
const int count = 4;
for(int i = 0; i < count; i += 1){
pessoa[i].num = i;
}
for (int i = 0; i < count; i += 1)
{
printf("%d\n", pessoa[i].num);
}
system("pause");
return 0;
}
Exit from the program
0
1
2
3
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero