C: Why isn't size_t a C keyword?

前端 未结 10 1985
鱼传尺愫
鱼传尺愫 2020-12-28 14:18

sizeof is a C keyword. It returns the size in a type named size_t. However, size_t is not a keyword, but is

10条回答
  •  情话喂你
    2020-12-28 14:52

    The simple reason is because it is not a fundamental type. If you look up the C standard you will find that fundamental types include int, char etc but not size_t. Why so? As others have already pointed out, size_t is an implementation specific type (i.e. a type capable of holding the size in number of "C bytes" of any object).

    On the other hand, sizeof is an (unary) operator. All operators are keywords.

提交回复
热议问题