Cross-platform primitive data types in C++

前端 未结 7 2435
鱼传尺愫
鱼传尺愫 2021-02-14 07:04

Unlike Java or C#, primitive data types in C++ can vary in size depending on the platform. For example, int is not guaranteed to be a 32-bit integer. Various compi

7条回答
  •  鱼传尺愫
    2021-02-14 07:22

    Two things:

    First, there is a header file called limits.h that gives lots of useful platform specific information. It will give max and min values for the int type for example. From that, you can deduce how big the int type is.

    You can also use the sizeof operator at runtime for these purposes too.

    I hope this helps . . .

    K

提交回复
热议问题