| ??? 03/01/10 11:37 Read: times |
#173679 - such a 'newb' error (sic) Responding to: ???'s previous message |
Kai Busuttil said:
UGH That semicolon! Bugger I didn't notice the semicolon, was half asleep while writing the code. Although it's a very easy mistake to make it can, as you say, be a real #@*&%$ to spot - even for seasoned users! Probably would have worked if the semicolon wasn't there. It is working in that it's doing what the code specifically says - the problem is that what the code says is not what you actually wanted to do! This is a fine example of how a piece of code can compile without errors, and run without crashing, yet not produce the result that you wanted. It is very important to understand the difference between the syntax & sematics errors that can be spotted by the compiler, and this type of coding error - which cannot. ... if I recall well can be done in plain old fashioned C. What do you mean by, "plain old fashioned C"? ... the string compare command ... It's not a "command"; it's a call to a function - and that function just happens to be provided as part of the standard 'C' library. Note that the standard 'C' library is plain, old fashioned 'C'! ... resulted in a shorter code, hence a more elegant solution. Note that shorter source code does not equate to smaller executable code. In this case, as previously noted, it is unlikely that a hand-coded 'C' loop can beat (either on size or speed) the compiler's own strcmp library function - which should have been carefully optimised by the compiler maker. But calling something apparently (sic) simple like printf can add a huge amount to your executable! Floating point is another key example. now I feel a little bit stupid for not having noticed such a 'newb' error No - nothing to feel stupid about there! |
| Topic | Author | Date |
| Question about KEIL | 01/01/70 00:00 | |
| It ain't how i would do it | 01/01/70 00:00 | |
| Thank you! | 01/01/70 00:00 | |
| using strncmp for a password check is a bug :^) | 01/01/70 00:00 | |
| Yeah whatever | 01/01/70 00:00 | |
| Interesting | 01/01/70 00:00 | |
| Eh?? | 01/01/70 00:00 | |
40 instead of 50000000 | 01/01/70 00:00 | |
| Nothing to do with Keil | 01/01/70 00:00 | |
| Hmmm I see | 01/01/70 00:00 | |
| Problem solved! | 01/01/70 00:00 | |
| Do you undrestand why it did not work? | 01/01/70 00:00 | |
| Wrong | 01/01/70 00:00 | |
| Yes, it's wrong - but... | 01/01/70 00:00 | |
| code size decrease | 01/01/70 00:00 | |
| Maybe | 01/01/70 00:00 | |
| After a nights sleep | 01/01/70 00:00 | |
| Where it gets specific to Keil (or whatever) | 01/01/70 00:00 | |
| Explain | 01/01/70 00:00 | |
| Woops. | 01/01/70 00:00 | |
| such a 'newb' error (sic) | 01/01/70 00:00 | |
| Password application | 01/01/70 00:00 |



