In C, how do I create a `static` array of constant size with zeroed
values, but without calloc?
I currently have some code in a function that looks like this:
static const int kFrameCountSample = 250;
static float * samples = (float *)calloc(kFrameCountSample,
sizeof(float));
I like that the samples array is zeroed out exactly once with calloc().
I can also write the code so samples is allocated on the stack.
static const int kFrameCountSample = 250;
static float samples[kFrameCountSample];
but now samples is not initialized to zero values. How would I also
initialize it at the time it is allocated?
No comments:
Post a Comment