QP School
Using = instead of == in C - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32)
+--- Thread: Using = instead of == in C (/showthread.php?tid=5118)



Using = instead of == in C - Qomplainerz - 07-26-2023

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");
}