Where do I find the definition of size_t?

前端 未结 9 2162
醉酒成梦
醉酒成梦 2020-11-28 04:37

I see variables defined with this type but I don\'t know where it comes from, nor what is its purpose. Why not use int or unsigned int? (What about other \"similar\" types?

9条回答
  •  Happy的楠姐
    2020-11-28 04:46

    size_t is the unsigned integer type of the result of the sizeof operator (ISO C99 Section 7.17.)

    The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is an integer. The value of the result is implementation-defined, and its type (an unsigned integer type) is size_t (ISO C99 Section 6.5.3.4.)

提交回复
热议问题