char cMsg[128][12];
is the same this:
ZeroMemory(cMsg, sizeof(cMsg));
than this?
for(i=0;i<128;i++)
ZeroMemory(cMsh[i], sizeof(cMsg[i]))
compilers gives no error with both ways, but are they metods for same objective?
The behavior is going to be the same for char arrays, because they have no alignment requirements or padding bytes in the middle. The first way of doing it may be a little faster than the second one, because it uses fewer function calls, the speed-up would be too small to measure reliably on modern hardware, and the net result is going to be the same.
Yes.
ZeroMemory zeroes a block of memory, and arrays are contiguous.
So, zeroing out the entire block in "chunks" rather than all in one go is functionally the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With