I thought when you define an empty array like this
char t[2000] = "";
it would set all elements of that array to 0
, but when I create a 2000 size array, the 2000th element is not 0
. Same thing with 3000 size array, but other sizes like 100, contain all zeroes.
Why aren't all the elements 0
?
#include <stdio.h>
int main() {
char t[2000] = "";
for (int i; i <= 2000; i++) {
if (t[i] != 0) {
printf("\n\nt[%i] is not 0\n\n\n", i);
}
printf("t[%i] = %i\n", i, t[i]);
}
return 0;
}