I read about int vs size_t vs ssize_t , and I understand that int and ssize_t is signed while size_t is unsigned.
Why memcmp
return int and no return ssize_t like recv
return ssize_t?
An int
is sufficient to hold the return value of memcmp
.
The memcmp
function returns 0 if the two given memory regions are equal, a value less than 0 if the first region compares less, and a value greater than 0 if the first region compares more.
A ssize_t
may be larger than an int
(and on most implementations it will be), and an int
is typically the "natural" word size, so there is no benefit to using the larger size.