Say I want to initialize myArray
char myArray[MAX] = {0};
char myArray[MAX] = {0,};
char myArray[MAX]; memset(myArray, 0, MAX);
They are equivalent regarding the generated code (at least in optimised builds) because when an array is initialised with {0}
syntax, all values that are not explicitly specified are implicitly initialised with 0, and the compiler will know enough to insert a call to memset
.
The only difference is thus stylistic. The choice will depend on the coding standard you use, or your personal preferences.