Why size_t when int would suffice for the size of an array?

后端 未结 5 1873
[愿得一人]
[愿得一人] 2021-01-17 13:09

The C standard guarantees that an int is able to store every possible array size. At least, that\'s what I understand from reading §6.5.2.1, subsection 1 (Array

5条回答
  •  星月不相逢
    2021-01-17 13:50

    size_t is a typedef of unsigned integer (such as int or long).

    In some 64bit platforms, int can be 32bit, while size_t can be 64bit.

    It is used as a more standard way for size.

提交回复
热议问题