Four Basic Data Types of C

  • 2021-12-11 08:37:13
  • OfStack

Character type char, which stores 1 character enclosed in ''(single quotation marks), for example:

char sex='男';//存储性别

String type string, which stores a string of 1 characters enclosed in "" (double quotation marks), for example:

string address="北京市宣武区牛街北口";//存储地址

Integer type int, which stores integers, for example:

int age=23;//存储年龄

Double-precision floating-point double, which stores decimals, such as:

double salary=7991.63;//存储工资

The above four are the most commonly used data types.

It should be noted that a certain type of variable can only store this type of data, otherwise, errors may occur.


Related articles: