How to initialise data with 0 while reallocating in C?

Viewed 28

I have an array of char, and want to dynamically allocate it while initialising each element with 0.

For the first time, I can do this with calloc(), but for next times, I will be forced to use realloc(), which of course does not initialise the data.

Note that I only want to initialise those amounts of bytes which have been reallocated.

How can I do that? Thank you in advance.

0 Answers
Related