Summary of C language data types

Source: Internet
Author: User

Analogy is a good way to learn a new language, and here we look at the data types of the C language in the Java language.


The C language provides a rich data type, and the following chart is a good representation of all C language data types:

It is possible to see that the C language provides Java the language does not have the structure, the common body and the pointer type, at the same time C language lacks in Java the Boolean type namely the Boolean,c language and the Java difference also the body today each type occupies the number of bits, concrete see:

Here are a few things to consider when using various types
1. Integral type
Integer constants have three decimal types in the C language. Each is decimal, octal, and hexadecimal. When used, the decimal number starts with a number other than 0, the octal number starts with 0, the hexadecimal digit starts with 0x, and the binary is converted to each other.

For example, you can direct printf("%d",0x567) , other conversions and so on.


2, floating-point type
The use of floating-point types is double by default. If you want to use a float type, you should add F or F to the number behind it.
Floating-point constants can be represented by exponents. Use e to indicate a power of 10, for example: 1.23e4=1.23*10^4.
When using the printf("%f",1.23456) output, the default is to retain 6 digits after the decimal point, assuming that you want to set up, you can use%.XF, where x represents the number of bits you want to output, such as printf("%.3f",1.2345) will output 1.235.
Floating-point types are divided into two parts when the computer is stored: mantissa and exponent. The number of tails is the number of valid digits, the more the number of tail parts, the more accurate the numbers are expressed.

The value range of the exponent is determined by the number of digits, the greater the number of values. Valid numbers for float and double are for example the following:

3, Character type
Java uses a 16-bit Unicode encoding to store numeric values of type char, while the C language uses 8-bit ASCII encoding for storage.
The C language is escaped with "\" as an escape character. The specific escape character descriptor is as follows:

Summary of C language data types

Related Article

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.