Length of various data types in the C language

Source: Internet
Author: User

On 32-bit platforms and 64-bit platforms, the same data type may have different data lengths:

Type 32-bit Platform 64-bit Platform
Char 1 1
Short 2 2
Int 4 4
Long 4 8
Long Long 8 8
Float 4 4
Double 8 8
size_t 4 8
ssize_t 4 8

See, No,

You can see the difference from the above results, so don't assume the data length of the color background row in the table above, because it will change.

Because the functions of the system return these values, you must know their size and make the appropriate error-proof conversion. In other cases, you need to fix the data length data type across different platforms, and you can use some fixed-length data types, which will not be confusing, like this:

int8_t int16_t int32_t int64_t

uint8_t uint16_t uint32_t uint64_t

Length of various data types in the C language

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.