memset (C/C++)
First introduced to this through Competitive Programming.
memset is a C function that sets a block of memory to a particular byte value.
Typical Usage
memset(dp, 0, sizeof(dp));Danger
Note that this generally works with 0, if you try other values than 0, it won’t work.
- This is because
memsetworks on a per-byte basis, so when you give it a non-zero value, it will apply that value to each byte in the block of memory, not to the elements themselves.