??? 09/06/06 17:11 Modified: 09/06/06 17:14 Read: times |
#123768 - style does not apply to C only Responding to: ???'s previous message |
Andy Neil said:
Jon Ledbetter said:
putchar(key + 48); // display ascii value It's generally clearer to write:putchar(key + '0'); // display ascii value It's the same in asm, and any other language. You should write it as readable for the human as possible (oh yes, why C then? :-) ); don't care about the machine, it's a slave anyway :-) . mov a,key add a,#'0' call putchar Gosh, the above (if ((key >= 0) & (key <= 9))) is a perfect example. In asm, it's a bunch of absolutely unreadable cjne's. In C, it's a little bit more readable, but still a bunch of non-alphanumeric characters, still not really for human; I'd still call it "code" rather than "program". Pascal would perhaps say "if (key >= 0) and (key <= 9)", but, hey, Pascal might also say "if key in [0..9]", or, with a bit of preparation, also "if key in digits". JW, the C hater |
Topic | Author | Date |
A learning 'C' speed bump | 01/01/70 00:00 | |
Uninitialised? | 01/01/70 00:00 | |
Variables were initialized. | 01/01/70 00:00 | |
logical vs bitwise | 01/01/70 00:00 | |
this is when the C people try to be smart... | 01/01/70 00:00 | |
Ok, corrected the && ... | 01/01/70 00:00 | |
check the size of the variables | 01/01/70 00:00 | |
I Ceed it already | 01/01/70 00:00 | |
Style | 01/01/70 00:00 | |
style does not apply to C only | 01/01/70 00:00 | |
words | 01/01/70 00:00 | |
Does it?? | 01/01/70 00:00 | |
Verification | 01/01/70 00:00 | |
oh come on... | 01/01/70 00:00 | |
RESOLVED | 01/01/70 00:00 | |
variable scope | 01/01/70 00:00 |