You haven't said how the code failed, so I can't be sure.
That said, I have a guess. My guess is that you are not fully filling in all the arrays when reading from the file (perhaps your arrays are 1 element too long, for example. Or maybe 100 too long, I have no way of knowing). I would guess that when you subsequently process the data, if you hit an array where all the values are 0, your processing basically does nothing (i.e. it loops 0 times, for example), which is safe. So, when you initialize the arrays, any unused entries are all 0s and your subsequent processing "works" by doing nothing. However, if you don't initialize them, then your subsequent processing hits garbage data and maybe tries to loop a billion times, or 53 times, or whatever, and it fails on the junk data it gets.
If that is the case, initializing the array didn't actually fix anything, it just forced the code into a safe mode of failure (trying to process uninitialized entries is a failure state, but if they are zeroed, it is harmless), whereas without the data being initialized, you have a potentially unsafe mode of failure.
That is just my guess. There is nowhere near enough information here to do much better than that. How exactly did it fail (exact error messages are helpful). Was it always the same failure or did it change each time you ran it (all else, like file contents, held equal)? Are you absolutely 100% certain the arrays are always filled in, no matter what happens and what is in the files?
This is why we always ask people to post all their code and relevant data files, and give exact error messages. Without knowing exactly what you did, we have no way to know what happened (and if you are running a different OS than I am, I might not be able to reproduce it because things change OS to OS, let alone CPU architecture to CPU architecture, so knowing what errors you saw lets us debug even if we can't reproduce).
Also, just because something is "just a warning" doesn't mean the code won't fail to work as expected.
Try this out:
Code:
#include <stdio.h>
int main() {
int x=-1;
unsigned int max=x;
for(unsigned int i=0;i<max;++i) {
printf("%d\n",i);
}
return 0;
}
( You will probably want to ^C that )
That has "just a warning" but it almost certainly "doesn't work" by any reasonable definition of working. It is best to treat warnings as errors that have a high enough false-positive rate that they can't be made errors. Almost every time they occur, something has gone wrong, though a few cases are things where the compiler is actually wrong and the code is fine. But generally speaking, never assume that is the case. Unless you can prove it is the case, treat the warning as an error.