unsigned int vs. size_t

前端 未结 8 1813
悲哀的现实
悲哀的现实 2020-11-22 07:16

I notice that modern C and C++ code seems to use size_t instead of int/unsigned int pretty much everywhere - from parameters for C str

8条回答
  •  眼角桃花
    2020-11-22 07:59

    size_t is the size of a pointer.

    So in 32 bits or the common ILP32 (integer, long, pointer) model size_t is 32 bits. and in 64 bits or the common LP64 (long, pointer) model size_t is 64 bits (integers are still 32 bits).

    There are other models but these are the ones that g++ use (at least by default)

提交回复
热议问题