C Language 32 Keywords

Source: Internet
Author: User
Tags goto modifier volatile

Keywords are words that have been used by the C language itself and cannot be used for other purposes. For example, a keyword cannot be used as a variable name, a function name, etc.

A total of 32 C language keywords are defined by the ANSI standard:

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

According to the role of the keyword, you can divide the keywords into data type keywords and process Control keywords two broad categories.

  1 Data type keywords

A. Basic data types (5)

  void : Declares that the function has no return value or no arguments, declares an untyped pointer, and explicitly discards the result of the operation

  Char : Character type data, which belongs to an integer type of data

  int : integer data, usually the machine word length specified by the compiler

  float : single-precision floating-point data, a type of floating-point data

   Double: double-precision floating-point data, a type of floating-point data

B. Type modifier keywords (4)

   short: Modifies int, and it can omit the modified int.

   long: modifier int, long shaping data, can omit the decorated int.

  signed : Cosmetic integer data, signed data type

  unsigned : Cosmetic integer data, unsigned data type

C. Complex Type Keywords (5)

  struct : structure declaration

  Union : Shared Body Declaration

  enum : enum declaration

  typedef : declaring type aliases

  sizeof : To get the size of a particular type or variable of a particular type

D. Storage-level Keywords (6)

   Auto: Designated as an automatic variable, automatically assigned and released by the compiler. Usually allocated on the stack

   Static: Specified as a statically variable, assigned to a static variable area, when the function is decorated, the specified function scope is inside the file

  Register : specified as a register variable, it is recommended that the compiler store variables in registers, or you can modify function parameters, and it is recommended that the compiler pass arguments through registers instead of stacks

  extern : Specifies that the corresponding variable is an external variable, that is, the definition of the marked variable or function in another file, prompting the compiler to find its definition in other modules when it encounters this variable and function.

  Const : and volatile collectively "CV characteristics", specify that the variable cannot be changed by the current thread/process (but may be changed by the system or other threads/processes)

  volatile : with const collectively "CV characteristics", the value of the specified variable may be changed by the system or other processes/threads, forcing the compiler to get the value of the variable every time from memory

  2 Process Control keywords

A. Jump Structure (4)

   return: In the function body, returns a specific value (or void value, that is, does not return a value)

  continue : End current loop, start next round loop

   break: Jump out of the current loop or switch structure

  goto : Unconditional Jump Statement

B. Branch structure (5)

  if : conditional statement, do not need to place a semicolon after

  Else : Conditional Statement Negative branch (used with IF)

   Switch: Switching statements (multiple branch statements)

   Case: Branch marks in a switch statement

  default : The "other" branch in the switch statement, optional.

C. Circulation structure (3)

  for: The For loop structure, for (1;2;3) 4, the Order of execution is 1->2->4->3->2 ... loop, where 2 is the cyclic condition. In the entire for loop, expression 1 is evaluated only once, and expression 2 and expression 3 may be calculated multiple times or not at once. The loop body may execute multiple times, or it may not execute at once.

   do: Do loop structure, do 1 while (2); The order of execution is 1->2->1 ... loops, 2 for cyclic conditions

   while: While loop structure while (1) 2; The order of execution is 1->2->1 ... loops, 1 for cyclic conditions

The above loop statement, when the loop condition expression is true, continues the loop, and then jumps out of the loop for false.

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.