Introduction to data types in C language


1. What are the data types in C language?

Data types in C language can be divided into integer types, floating point types, character types and Boolean types. Let us take a look at them below.

2. Data type classification

1. Integer type

short  //短整型     
int    //整型       
long   //长整型      
long long //更长的整数    

Code:

printf("%d\n", sizeof(short));//长度为2
printf("%d\n", sizeof(int));  //长度为4
printf("%d\n", sizeof(long)); //长度为4
printf("%d\n", sizeof(long long));//长度为8

2. Floating point type

float   // 精度点浮点数   
double  // 双精度浮点数

代码:

printf("%d\n", sizeof(float));//长度为4
printf("%d\n", sizeof(double));//长度为8

3.Character type

char // character type

Code:

	printf("%d\n", sizeof(char)); //长度为1

4. Boolean type

bool // Boolean type

Special note: The C language itself does not directly support the Bool type, and the header file needs to be introduced:stdbool.h

Code:

printf("%d\n", sizeof(bool)); //长度为1

3. Summary:

    The basic types of C language can be divided into four types: integer type, floating point type, character type and Boolean type.

    Integer types: short (2 bytes), int (4 bytes), long (4 bytes), longlong (8 bytes).

    Floating point type: float (4 bytes), double (8 bytes).

    Character type: char (1 byte).

    Boolean type: bool (1 byte).

This article is over. If the content is wrong or the explanation is incomplete, you are welcome to comment positively!

      

                

Guess you like

Origin blog.csdn.net/code_beihuan/article/details/134516658