WelcomeUser Guide
ToSPrivacyCanary
DonateBugsLicense

©2025 Poal.co

(post is archived)

[–] 1 pt

It basically boils down to if(expression != 0) do_this();

It's up to the programmer to come up with a sensible expression. It's common to use

'while(true) { do_stuff(); if(condition) break; }`

The expressions will be zero (false) or non-zero (true). Usually you wouldn't want a constant expression in a conditional statement, but there are exceptions (to force code to run for debugging purposes for instance).

They do keep working on ways to keep programmers from doing stupid things; but with C it's kind of like you're following policies that were set before OSHA came into being. The scaffolding lets you get where you need to go, but you need to be careful not to fall off while you're working.

[–] 1 pt (edited )

The expressions will be zero (false) or non-zero (true).

Yeah ok, so, "if(myVar = true)" essentially means "if(true)", in C/C++... Or any other language allowing such stunts. Makes sense. And at the same time it makes no sense whatsoever; the conditional check becomes an affectation, so it's not a conditional check it's just lame

...

[–] 0 pt

Back in the day they wrote the first C compiler, they were interacting with serial-enabled typewriters. If they could write if(a=f(x))g(); they would do that over a = perform_function_f(x); if (a != 0 ) { perform_fuction_g(); } else { /* do nothing */ }

[–] 0 pt

>if(a=f(x))g();

I don't see why you would need to store the value of f(x) in "a" on this one, and I don't think that "back in the day" they just couldn't write if( f(x) ) g();