| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Pointers |
1237cf58aab2 c_echo Hello Bob - --8<--cut BS> This seems like a good time to remind folks of one of the BS> oldest C programming "tricks"... When doing comparisons, BS> always put the constant on the left side of the expression. BS> For inequality and greater/less than comparisons, it makes BS> no difference, but it sure does when testing for equality! BS> Since using "=" when you mean "==" is one of the most BS> common mistakes (usually, it's a typo and is even made by BS> experienced C programmers), putting the constant on the BS> left changes the compiler's action from a warning to an BS> error. BS> if (x == 6) /* what you mean */ BS> if (x = 6) /* warning, possible unintended assignment */ BS> if (6 = x) /* error, assignment to a constant */ BS> During early stages of testing, it's not uncommon to turn BS> down the warning level a bit or to simply ignore warnings BS> if the program appears to compile properly. This particular BS> little typo can therefore quite easily slip past you BS> depending on the context and the specifics of your test BS> data. All good/useful information, thanks. > , , > o/ Charles.Angelich \o , > __o/ > / > USA, MI < \ __\__ ___ * ATP/16bit 2.31 * ... DOS the Ghost in the Machine! http://www.undercoverdesign.com/dosghost/ --- Maximus/2 3.01* Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000) SEEN-BY: 633/267 270 @PATH: 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.