Is it good practice to initialize array in C/C++?
- by sand
I recently encountered a case where I need to compare two files (golden and expected) for verification of test results and even though the data written to both the files were same, the files does not match.
On further investigation, I found that there is a structure which contains some integers and a char array of 64 bytes, and not all the bytes of char array were getting used in most of the cases and unused fields from the array contain random data and that was causing the mismatch.
This brought me ask the question whether it is good practice to initialize the array in C/C++ as well, as it is done in Java?