Difference between size_t and unsigned int?

后端 未结 7 1073
清酒与你
清酒与你 2020-11-28 01:29

I am so confused about size_t. I have searched on the internet and everywhere mentioned that size_t is an unsigned type so, it can represent only n

7条回答
  •  情书的邮戳
    2020-11-28 02:06

    size_t has a specific restriction.

    Quoting from http://www.cplusplus.com/reference/cstring/size_t/ :

    Alias of one of the fundamental unsigned integer types.

    It is a type able to represent the size of any object in bytes: size_t is the type returned by the sizeof operator and is widely used in the standard library to represent sizes and counts.

    It is not interchangeable with unsigned int because the size of int is specified by the data model. For example LLP64 uses a 32-bit int and ILP64 uses a 64-bit int.

提交回复
热议问题