Home>Article>Backend Development> What are the simple data types in C language?

What are the simple data types in C language?

青灯夜游
青灯夜游 Original
2019-03-01 15:00:00 142568browse

The simple data types in the C language are: 1. Integer type [int, short, long, long long]; 2. Floating point type [float, double]; 3. Character type [char].

What are the simple data types in C language?

The simple data types in C language are:

1. Integer (number) type

  • int: basic integer type, used to store integers, occupies 4 bytes; the default value is 0, data The range is -2147483648~2147483647

  • short: short integer, occupies 2 bytes, the storage method is the same as the basic integer, the data range is -32768-32767

  • long: long integer, occupies 4 bytes, the data range is -2^63~2^63-1

  • long long: double long integer type, occupies 8 bytes, and the data range is -2^63~2^63-1; this data type is generally less used.

2. Floating point type

  • float: single precision floating point type, accounting for 4 bytes, valid numbers are (6~7 digits), the data range is -3.4*10^38~ 3.4*10^38

  • float type variable is composed of limited storage The unit composition, therefore, can only provide a limited number of significant digits, and numbers outside the significant digits will not be precise, so some errors may occur.

  • double: double precision floating point type, occupies 8 bytes, valid digits are (15~16 bits), data range is -1.7*10^-308~1.7*10 ^308.

3. Character type

  • char: Character type, used to store a single character , accounting for 1 byte.

Note: In C language, char array is used to store strings. Example:

char c; c='a'; //是正确的, c="a"; //是错误的 c="abcd"; //是错误的 char string[4]; string="abcd"; //是正确的,

The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

The above is the detailed content of What are the simple data types in C language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn