您的位置:首页 > 理论基础 > 数据结构算法

c语言数据结构和数据类型_C语言中的数据类型

2020-07-31 13:36 1116 查看

c语言数据结构和数据类型

Data types specify how we enter data into our programs and what type of data we enter. C language has some predefined set of data types to handle various kinds of data that we can use in our program. These datatypes have different storage capacities.

数据类型指定了如何将数据输入到程序中以及输入什么类型的数据。 C语言具有一些预定义的数据类型集,以处理我们可以在程序中使用的各种数据。 这些数据类型具有不同的存储容量。

C language supports 2 different type of data types:

C语言支持2种不同类型的数据类型:

  1. Primary data types:

    主要数据类型

    These are fundamental data types in C namely integer(

    int
    ), floating point(
    float
    ), character(
    char
    ) and
    void
    .

    这些是C语言中的基本数据类型,即integer(

    int
    ),浮点数(
    float
    ),character(
    char
    )和
    void

  2. Derived data types:

    派生数据类型

    Derived data types are nothing but primary datatypes but a little twisted or grouped together like array, stucture, union and pointer. These are discussed in details later.

    派生数据类型不过是主要数据类型,而是有点扭曲或组合在一起的数组结构联合指针 。 这些将在后面详细讨论。

Data type determines the type of data a variable will hold. If a variable

x
is declared as
int
. it means x can hold only integer values. Every variable which is used in the program must be declared as what data-type it is.

数据类型确定变量将保存的数据类型。 如果变量

x
声明为
int
。 这意味着x只能容纳整数值。 程序中使用的每个变量都必须声明为数据类型。

整数类型 (Integer type)

Integers are used to store whole numbers.

整数用于存储整数。

Size and range of Integer type on 16-bit machine:

16位计算机上整数类型的大小和范围:

TypeSize(bytes)Range
int or signed int2-32,768 to 32767
unsigned int20 to 65535
short int or signed short int1-128 to 127
unsigned short int10 to 255
long int or signed long int4-2,147,483,648 to 2,147,483,647
unsigned long int40 to 4,294,967,295
类型 大小(字节) 范围
int或signed int 2 -32,768至32767
无符号整数 2 0至65535
short int或有符号short int 1个 -128至127
无符号short int 1个 0至255
long int或有符号long int 4 -2,147,483,648至2,147,483,647
无符号长整数 4 0至4,294,967,295

浮点型 (Floating point type)

Floating types are used to store real numbers.

浮点类型用于存储实数。

Size and range of Integer type on 16-bit machine

16位计算机上整数类型的大小和范围

TypeSize(bytes)Range
Float43.4E-38 to 3.4E+38
double81.7E-308 to 1.7E+308
long double103.4E-4932 to 1.1E+4932
类型 大小(字节) 范围
浮动 4 3.4E-38至3.4E + 38
8 1.7E-308至1.7E + 308
长双 10 3.4E-4932至1.1E + 4932

角色类型 (Character type)

Character types are used to store characters value.

字符类型用于存储字符值。

Size and range of Integer type on 16-bit machine

16位计算机上整数类型的大小和范围

TypeSize(bytes)Range
char or signed char1-128 to 127
unsigned char10 to 255
类型 大小(字节) 范围
字符或签名字符 1个 -128至127
无符号的字符 1个 0至255

空类型 (void type)

void
type means no value. This is usually used to specify the type of functions which returns nothing. We will get acquainted to this datatype as we start learning more advanced topics in C language, like functions, pointers etc.

void
类型表示没有值。 通常用于指定不返回任何内容的函数类型。 当我们开始学习C语言中更高级的主题(例如函数,指针等)时,我们将熟悉此数据类型。

翻译自: https://www.studytonight.com/c/datatype-in-c.php

c语言数据结构和数据类型

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: