Current location - Recipe Complete Network - Dinner recipes - What does+= mean in C language?
What does+= mean in C language?
+= is a compound assignment operator in C language. The compound assignment operator is formed by adding other operators before the simple assignment operator "=", such as+=,-=, * =,/=,% =.

Namely: a+= 1; Equivalent to a=a+ 1. += means to move the first symbol on the left to the right, which actually means b = b=b+c C. Move b+ of b+=c directly to the right, take out the value of B and then take out the value of C, add it up and assign it to B, and store it in the memory space opened by B. Similarly, b-=c and b*=c all mean this.

This writing allows optimization to be performed by addressing the address of A once, otherwise it needs to address A twice. However, the rapid development of cpu makes this optimization have no practical value decades ago, and it is only because of grammar compatibility and programmer habits that it is preserved.

Extended data

Types of operation symbols in C language

1, arithmetic operator

Used for all kinds of numerical operations. Including addition (+), subtraction (-), multiplication (*), division (/), remainder (or modular operation,%), self-increasing (++) and self-decreasing (-) * * *.

2. Relational operators

Used for comparison operation. Include those greater than (> ), less than (<; ), equal to (= =), greater than or equal to (> =), less than or equal to (<; =) and not equal to (! =) Six kinds.

3. Logical operators

Used for logical operations. Including with (&; & ), or (||), not (! ) three kinds.

4, bit operator

The quantity involved in the operation is calculated by binary bit. Include bits and (&; ), bitwise OR (|), bitwise NOT (~), bitwise XOR (), left shift (<; < ), move right (> > ) six kinds.

5. Assignment operator

Used for assignment operation, which is divided into simple assignment (=), compound arithmetic assignment (+=,-=, * =,/=,% =) and compound bit operation assignment (&; =,|=,^=,> > =,< < =) Three categories * * * eleven kinds.

6. Conditional operators

This is a three-eye operator used for conditional evaluation (? :)。

7. Comma operator

Used to combine several expressions into one expression (,).

8. Pointer operator

Used to fetch content (*) and address (&; ) two operations.

9, find the number of bytes operator

Used to calculate the sizeof the data type.

10, special operators

There are brackets (), subscripts [], members (→,.) and so on.

Baidu encyclopedia -C language operation symbol