4 ms·
... and screwed up by assuming v is an array of char, so the number elements is the size. What we want is: memset(v, 0, sizeof v); If this is intended to i
by kazinator 12y ago
... and screwed up by assuming v is an array of char, so the number elements is the size. What we want is:
memset(v, 0, sizeof v);
If this is intended to initialize v, this may be suitable:
int v[10] = { 0 }; /* or whatever type */
By the way, all-zero-bit memory is not required to give us null pointers or floating-point values of 0.0; it's just de facto very portable.
- nostrademons 12y agosizeof(v) is dangerous - if v is passed in (as opposed to being a local), it'll be the size of a pointer, not the full array. ...which is what we get for debating C in a thread that started with an example that isn't even legal C code.