QP School

Full Version: Using = instead of == in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Assigning a value using = instead of comparing with == in conditional statements.

// Incorrect
int x = 5;
if (x = 10) {
    printf("x is 10\n");
}

// Correct
int x = 5;
if (x == 10) {
    printf("x is 10\n");
}