Dev.to AI 🤖 Ai 👁 0

A Small Mistake in C That Took Me 30 Minutes to Fix

Today I got stuck on a very small problem in C. And honestly… it took...Read More The Code include int main() { int a = 5; if(a = 10) { printf("Value is 10"); } return 0; } At first glance

Today I got stuck on a very small problem in C.

And honestly… it took...Read More

The Code

include

int main() {
int a = 5;

if(a = 10) {
    printf("Value is 10");
}

return 0;

}

At first glance, everything looks fine.

But the output was not what I expected.

The Problem

I was using:

if(a = 10)

Instead of:

if(a == 10)
Why This Matters
= is used for assignment
== is used for comparison

So instead of checking the value...Read More

👉 I was actually changing the value of a

That’s why the condition was always true.

What I Learned

This small mistake taught me something important:

👉 Always pay...Read More

Because even a tiny symbol can completely change your program.

Final Thought

Sometimes the bug is not big.

It’s just one small mistake hiding in plain sight.

And those are the... Read More

Thanks for reading.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.