Char, char*, short, int, long, long long summary

Source: Internet
Author: User

Turn from: http://blog.sina.com.cn/s/blog_6f62c9510101svjz.html


The following words selected from the "C Programming language":

The introduction of the short and long two qualifiers can provide us with the number of different lengths that meet the actual needs. int typically represents the natural length of a certificate in a particular machine. The short type is typically 16-bit, the long type is typically 32-bit, and the int type can be 16-bit or 32-bit. Each compiler can choose the appropriate type length according to the hardware characteristics, but follow the following restrictions: the short and int types are at least 16 bits long, at least 32 bits, and the short type must not be longer than the int type, and the int type must not be longer than the long type.


The following passage is selected from "C++primer":

The short, int, and long types all represent integer values, with different sizes of storage space. Generally, the short type is half the length of the machine (word), the int is of one machine, and the long type is one or two machine words (the int type and the long type are the same in the 32-bit machine).


At this time I thought again, different machine position, these three types in the end what is the difference, short is not said, from the above two paragraphs, should be 16 digits, then int and long. First look at the list:

Type

16-bit System/byte

32-bit System/byte

64-bit System/byte

Char

1

1

1

char*

2

4

8

Short

2

2

2

Int

2

4

4

Long

4

4

8

Longlong

8

8

8

  

It can be seen from the table that the int type is 4 bytes 32 bits under the 64-bit system. And what this stuff is all about. Who is in control. From the Internet to pick up a variety of explanations, there are about two points:

1, 64-bit system, compiler for forward compatibility, the int type automatically compiled to 4 bytes of the;

2, these things are compiler to control, different compiler will type int to different lengths, so, use what compiler is important, such as: 32-bit system, TC int is 16-bit length, VC is 32-bit length.

3, Long Long is the standard 8 bytes, is not limited by the compiler, so, 16-bit is still 8 bytes.

  

Through the above introduction, you should have a general understanding of the definition of the bar, so we use the integer variable when we still need to be careful, especially when it takes up the length of space, do not assume that int in 32-bit system is 4 bytes. Try to use sizeof value.

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.