32 keywords in C Language

Source: Internet
Author: User

Keywords are words that have been used by the C language itself and cannot be used for other purposes. For example, keywords cannot be used as variable names or function names.

 

A total of 32 C language keywords defined by ANSI:

 

Auto double int struct break else long switch

 

Case Enum register typedef char extern return Union

 

Const float short unsigned continue for signed void

 

Default goto sizeof volatile do if while static

 

Keywords can be divided into two categories: Data Type keywords and process control keywords.

 

  1. Data Type keywords

 

  A. Basic data types (5)

 

  Void: Declares that the function has no return value or no parameter, declares that there is no type pointer, and explicitly discards the operation result.

 

  Char: String type data, which is a type of integer data.

 

  Int: Integer data, usually the machine font specified by the compiler

 

  Float: Single-precision floating point data, a type of floating point data

 

  Double: Double-precision floating point data, which is a type of floating point data.

 

  B. type modification keywords (4)

 

  Short: Modify int and short integer data. The modified int can be omitted.

 

  Long: Modifies int and long integer data. The modified int can be omitted.

 

  Signed: Modify integer data, Signed Data Type

 

  Unsigned: Modify integer data, unsigned Data Type

 

  C. Complex Type keywords (5)

 

  Struct: Struct Declaration

 

  Union: Shared body Declaration

 

  Enum: Enumeration Declaration

 

  Typedef: Declared type alias

 

  Sizeof: Get the size of a specific type or a specific type of Variable

 

  D. Storage-level keywords (6)

 

  Auto: Automatically assigned and released by the compiler. Usually allocated on the stack

 

  Static: It is specified as a static variable and allocated in the static variable area. When modifying a function, it is specified as a function scope within the file.

 

  Register: It is specified as a register variable. It is recommended that the compiler store the variable in the register or modify the function parameters. It is recommended that the compiler PASS Parameters through the register instead of the stack.

 

  Extern: Specify the corresponding variable as an external variable, that is, the variable or function definition is indicated in another file, prompting the compiler to find its definition in other modules when encountering this variable and function.

 

  Const: Used in conjunction with volatile, the specified variable cannot be changed by the current thread/process (but may be changed by the system or other threads/processes)

 

  Volatile: In combination with const, "CV feature" indicates that the value of a specified variable may be changed by the system or other processes/threads, forcing the compiler to obtain the value of this variable from the memory each time.

 

  2. Process Control keywords

 

  A. Jump structure (4)

 

  Return: Used in the function body to return a specific value (or void value, that is, no return value)

 

  Continue: Ends the current cycle and starts the next cycle.

 

  Break: Jump out of the current loop or switch structure

 

  Goto: Unconditional jump statement

 

  B. Branch Structure (5)

 

  If: Condition Statement, which does not need to be followed by a semicolon

 

  Else: The Condition Statement denies the branch (used with if)

 

  Switch: Switch statement (multi-branch Statement)

 

  Case: Branch mark in the switch statement

 

  Default: "Other" branch in the switch statement. Optional.

 

  C. Loop Structure (3)

 

  For: For loop structure, the execution sequence of for (1; 2; 3) 4; is 1-> 2-> 4-> 3-> 2... loop, where 2 is the cycle condition. During the for loop process, expression 1 is calculated only once. Expression 2 and expression 3 may be calculated multiple times or once. The loop body may be executed multiple times or not at all.

 

  Do: Do loop structure, do 1 while (2); the execution order is 1-> 2-> 1... loop, 2 is the loop Condition

 

  While: While loop structure, while (1) 2; the execution order is 1-> 2-> 1... loop, 1 is the loop Condition

 

In the preceding loop statement, if the expression of the loop condition is true, the loop continues. If the expression is false, the loop jumps out.

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.