Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

Simple assignment operator (=)

The = operator stores a value in the object on its left. Do not confuse assignment with equality comparison == or initialization.

Version: C23; repository compiler flag, production runtime not attested

Syntax

left = right

left = right requires a modifiable lvalue on the left. The right value is converted to the destination type; types must satisfy assignment constraints.

The result is the stored value, but not an lvalue. a = b = 7 means a = (b = 7). Associativity does not establish operand evaluation order: operands are unsequenced.

= assigns; == compares. In the declaration int a = 0;, = denotes initialization, not the assignment operator.

Examples

#include <stdio.h>

int main(void)
{
    int a = 0;
    int b = 0;
    a = b = 7;
    printf("%d %d\n", a, b);
    return 0;
}

Result

7 7

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources