32 keywords in C Language

Source: Internet
Author: User

First Keyword: Auto

Used to declare automatic variables. You can explicitly declare variables as automatic variables. As long as the variable is not declared before all functions, even if the auto keyword is not added, it is also an automatic variable by default. And only valid in the declared function. And after use, its value is automatically restored to the original value. Assign values to automatic variables because they contain unknown values. Example: auto int name = 1;

Second Keyword: static

Used to declare static variables. You can explicitly declare variables as static variables. It is also a local variable. Valid only in the declared function. Its life cycle starts from the beginning of the program to the end of the program. And even after use, its value is still not restored. It is automatically initialized to 0 even if no value is assigned to the static variable. For example, static int name = 1.

Third Keyword: extern

Used to declare global variables. The variables declared before the main function are also called global variables. It can be used anywhere in the program. It always exists during the program running. The global variable is also initialized to 0. For example, extern int name;

Fourth Keyword: Register

Used to declare as a register variable. It is also a local variable and only valid in the declared function. It is stored in registers. The speed is much faster. Using it to declare variables that need to be frequently used increases the program running speed. Example: Register int name = 1;

Fifth Keyword: int

Used to declare the type of a variable. Int is an integer. Note that the range of the 16-bit and 32-bit systems is different. The 16-bit occupies 2 bytes. The 32-bit occupies 4 bytes. It can also be explicitly declared as unsigned or signed: Unsigned int signed Int. The difference between signed and unsigned is that the symbol bit is also stored as a digit. You can also declare short and long as short integers or long rows. Example: int num;

Sixth Keyword: Float

Used to declare the type of a variable. Float is a float type, also called a real type. Its range is fixed to 4 bytes. The six digits are decimal places. Others are integer digits. Example: Float name;

Seventh Keyword: double

It is declared as a double-precision type. The value range is 8 bytes. The 14 digits are decimal places. You can also use a long double with a higher precision, which has a larger range of 10 bytes. Example: double name;

Eighth Keyword: struct

Declares the struct type. Struct can contain various types of quantities. For example, variable types such as integer and struct can be declared in the same struct type, and can be directly called using struct variables when used. Example: struct some {

Int A = 1;

Flowat B = 1.1

Double = 1.1234567

} KKK;

In this way, you can use KKK. A to use the member variables in the struct. You can also explicitly use struct some AAA, BBB; to declare multiple struct variables.

Ninth Keyword: Char

It is used to define a variable as the variable type. Its range is usually 1 byte. It is represented by ASC | MA in the memory. Therefore, it can also be used with integer operations. You can also use unsigned or signed definitions. Sigened char unsigned char example: Char C;

Tenth Keyword: Break

Used to indicate interruption. It is generally used in a loop. Determine whether the conditions are met and then interrupt the current loop. Example: break;

11th keywords: continue

It is used to skip the statement after the current statement and continue the next loop. Example: continue;

12th keywords: Long

Declares the type of the long type. For example, long int long double.

13th keywords: If

The statement used to determine whether the statement meets the conditions. For example, if a = B

K = N;

 

14th keywords: Switch

Condition Selection Statement, which is often used to determine the conditions selected by the user to execute specific statements. For example, switch (name)

{

Case OK:

Printf ("yes, OK! ");

Break;

Case No:

Printf ("oh, no! ");

Default:

Printf ("error ..! ")

 

Break;

}

15th keywords: Case

Use with the switch. The example is the same as above.

16th keywords: Enum

Used to declare enumerated variables... Example: Enum day {one, two, three, four, five, six, seven };

 

 

Key sub-Statement of 17th: typedef

Type redefinition... type can be redefined, for example, typedef unsigned int u_int; // defines the unsigned integer as u_int.

18th keywords: return;

Return Statement. Returns a value. When we define a function as a function with a returned value, we must return a value.

19th keywords: Unio

Define a joint object. The usage is the same as that of struct. The difference is that all Members of the shared object share the bucket.

Unio KKK {

Int;

Float B;

} Kka;

20th keywords: const

Defined as a constant... For example: const int A; // The value of variable A cannot be changed.

21st keywords: Unsigned

The default variables are all signed unless they are declared as unsigned.

22nd keywords:

Loop statement. You can specify how many times the program loops. Example: For (INT I = 0; I <5; I ++)

{

Printf ("the program will output five times! ");

}

23rd keywords: signed

Declare the variable as a signed variable. The default variable is signed. Generally, this parameter can be omitted.

24th keywords: void

Null type... It is generally used to declare that a function has no return value or no parameter.

25th keywords: Default

Used in the switch statement. Define the default processing. For the usage, see switch.

26th keywords: GOTO

Unconditional loop statement. Example: int I = 1;

W_go:

I ++;

If (I <5)

Goto w_go;

Else

Printf ("% d", I );

27th key subwords: sizeof

The storage space used to obtain the variables. For example, int A, B;

B = sizeof ();

28th keywords: Volatile

Declare the variable as variable. Use volatile int A. The specific usage is still not clear. Mark ..!!

29th keywords: Do

It is generally used with the while statement in the form of do while or while do. For example, see the while statement.

30th keywords: While

Loop Control statement. As long as the expression is true, it will keep repeating. For example: Do

Int A = 1;

While (A> 1)

Printf ("A> 1 ");

31st keywords: else

It is often used together with if. For example, if a = B

K = N;

Else

K = s;

32nd keywords: short

Declare a short integer variable: for example, short int;

Related Article

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.