size_t is a C variable type which is often used to contain the size of a memory area. While it is usually defined to be unsigned int, it is by no means guaranteed to be so! If you assume that size_t is the same as an unsigned int, your code might have problems on certain 64-bit machines.

Some examples of functions that use size_t:

In addition to this, C provides the sizeof operator. It returns the size of a variable or data type, so naturally size_t is its return value.

There are other types with similar uses to size_t. One (thanks tftv256) is ssize_t, which is a signed version. It allows functions such as write() to return a -1 for, say, an error indicator. Another is socklen_t, which serves only the mere purpose of holding the size of a struct sockaddr_t, for functions such as connect() and such.

There are likely more.

Log in or register to write something here or to contact authors.