C Language Third speaking, basic data types

Source: Internet
Author: User

C Language Third speaking, basic data type one, basic data type explanation

of the C languages, there are four basic data types, namely:

    • Plastic
    • Floating point Type
    • Pointer
    • Aggregation types (arrays and structs)

The whole family includes:

    • Character
    • Short-integer
    • Plastic
    • Long integer type

* * are divided into signed and unsigned differences * *

* * PS: It sounds like a long shape is as large as the value of a short integer, but not necessarily. * *

    • Rule: The long type is at least as long as the shape. While shaping should be at least as long as a short integer.

Range of values:

minimum range

char 

0~127

signed Char

-127 ~ 127

unsigned Char

0~255

short int

-32767~32767

unsigned Short int

0~65535

int

-32767~32767

unsigned int

0~65535

long int

-2147483647~ 2147483647

Unsigned Long int

0~4294967295

Floating point Type

In C, the keyword that defines a floating-point type is float

For example:

float 3.14f;

The suffix is f, which means floating-point type, and if not, then the double type is used.

Floating-point types are also divided into

Float

Double

Long double

Pointer type

In C language, the essence is the pointer, in fact, many beginners in learning pointers, will faint. In fact, the pointer is not difficult. The pointer is also a variable. It's just that the values in the store are different.

For example:

  

int  Ten ; int  0x456789 ; int *p = &a;

Observe the three lines of code,

The first sentence, a assigns a value of 10

Second sentence, B is assigned to a 16 binary value

In the third inning, P holds the address of a.

So if we think of the address of a as a 0x456789,

So P is actually a hexadecimal value, just like B.

It is only the content of P, which can be derived from the value of this address.

Ii. Aggregation Type

Aggregation type, which is an advanced type.

Array:

An array is characterized by saving data of the same data type. Access fast.

For example:

  

int p[10] = {1,2,3,4,5,6,7,8,9,10}; Define and initialize

In fact, it can also be defined as

int a = 1;int b = 2;int c = 3;.......int d = 10;

Defining an array is a convenient operation for our data.

Structure:

Structure, structure is mainly for the convenience of data management. Sometimes arrays are not as useful as data types.

So it is better to define the structure as the body.

  

struct mystruct{   int  A;    Double b;  };

 

Type minimum range char 0~127signed char-127 ~ 127Unsigned char0~255short int-32767~32767unsigned Short int0~65535int-32767~ 32767Unsigned Int0~65535long int-2147483647~2147483647unsigned Long int0~4294967295

C Language Third speaking, basic data types

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.