Home  >  Article  >  Detailed explanation of 32 keywords in C language

Detailed explanation of 32 keywords in C language

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-10-26 09:22:0916470browse

Detailed explanation of 32 keywords in C language

There are a total of 32 C language keywords defined by the ANSI standard. According to the function of the keywords, the keywords can be divided into two categories: data type keywords and process control keywords.

1. Data type keywords

A Basic data types (5)

void: Declaring that the function has no return Value or no parameters, declare an untyped pointer, display the discard destination result

char: character type data, a type of integer data

int: integer data, usually the compiler Specified machine word length

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 modification keywords (4)

short: Modifies int, short integer data, the modified int can be omitted

long: Modifies int , long integer data, the modified int can be omitted

signed: modified integer data, signed data type

unsigned: modified integer data, unsigned data type

Related recommendations: "php video tutorial"

C complex type keywords (5)

struct: structure declaration

union: union declaration

enum: enumeration declaration

typedef: declare type alias

sizeof: get the size of a specific type or a specific type or variable

D Storage level keywords (6)

#auto: Specify automatic, automatically allocated and released by the compiler. Usually allocated on the stack

static: designated as a static variable, allocated in the static variable area, when modifying the function, specify the scope of the function pointer to be inside the file

register: designated as a register variable, recommended The compiler stores variables in registers for use, and can also modify function parameters. It is recommended that the compiler passes parameters through registers instead of stacks

extern: Specify the corresponding variables as external variables, that is, defined in another target file , can be considered as a convention for variables declared in another file

const: together with volatile are called "CV characteristics". The specified variable cannot be changed by the current thread/process (but may be changed by the system or other threads/processes)

volatile: Together with const, it is called "CV feature". The value of the specified variable can be changed by the system or other threads/processes, forcing the compiler to obtain the value of the variable from 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 value is returned)

continue: end the current loop and start the next cycle

break: jump out of the current loop or switch structure

goto :Unconditional jump statement

B branch structure (5)

if:Conditional statement

else:Conditional statement negates the branch (used together with if )

switch: switch statement (multiple branch statements)

case: branch mark in the switch statement

default: "other" divide and conquer in the switch statement, optional

C Loop structure (3)

for: for loop structure, the execution order of for(1;2;3)4; is 1->2 ->4->3->2... loop, where 2 is the loop condition

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

while: while loop structure, while(1)2; execution sequence 1->2->1..., 1 is the loop For the above conditional loop statement, when the loop conditional expression is true, it will continue, and if it is false, it will jump out of the loop.

The above is the detailed content of Detailed explanation of 32 keywords in C language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more