The prototype of memset is void *memset(void *s, int c, size_t n);. So why the third parameter is of type size_t ? memset is just an example, I want more general reasons. Thanks in advance.
The prototype of memset is void *memset(void *s, int c, size_t n); . So
Share
size_tis the return type of thesizeofoperator and is used to describe memory sizes. In the case ofmemset, it specifies the number of bytes (n) in the memory block (s) that should be set to the given value (c).The size in bits of
size_tvaries based on the address space of the target platform. It does not always correlate to the register size. For example, in a segmented memory architecture thesizeof (size_t)can be smaller than thesizeof (void *). Typically,size_twould be 4 bytes on a 32-bit machine, 8 bytes on a 64-bit machine, etc.