= is the assignment operator, it stores the right-hand value into the left-hand variable and evaluates to that stored value. == is the equality comparison, it returns 1 if both sides are equal, 0 otherwise. The classic trap is if (x = 5), which assigns 5 to x and then treats the expression as the value 5, which is non-zero, so the branch always runs. The compiler can warn you about it with -Wparentheses. Defensive programmers sometimes write the constant on the left (if (5 == x)) so that a typo becomes a compile error.
Programming Fundamentals · Interview question
What's the difference between = and == in C?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Operators
Everything between the variables: the symbols that combine, compare, and change values. Learn the four families and the precedence rules that bite.