Eek - Can anyone spot the syntax-colouring 'errors'?
The code/colouring works fine in MSVC!
Just discovered this trick this afternoon and found it quite handy with all my debugging... wondered if anyone else uses it?
If I wanted to switch from the top code to the bottom code, I'd usually move the slash-star's around so that I get this:
But that's a lot of work... and I'm a lazy programmer who can't afford that many keystrokes. So, now I do this:
Notice the top section of code is commented-in (ie, will be compiled), but the bottom section is commented-out (ie, will be ignored). Now I can just remove a '//' and switch it round!
There. Simple.
Yes, it is a slow day
Just discovered this trick this afternoon and found it quite handy with all my debugging... wondered if anyone else uses it?
- Code:
// good code!
printf("elephants eat grass");
x = y * 14;
pNtr = pNtr + x;
/* // buggy code!
printf("elephants don't eat grass");
y = x * 14;
pNtr = pNtr - iApples;
*/
If I wanted to switch from the top code to the bottom code, I'd usually move the slash-star's around so that I get this:
- Code:
/*// good code!
printf("elephants eat grass");
x = y * 14;
pNtr = pNtr + x;
*/ // buggy code!
printf("elephants don't eat grass");
y = x * 14;
pNtr = pNtr - iApples;
But that's a lot of work... and I'm a lazy programmer who can't afford that many keystrokes. So, now I do this:
- Code:
// good code!
///* // note '//'
printf("elephants eat grass");
x = y * 14;
pNtr = pNtr + x;
/*/
printf("elephants don't eat grass");
y = x * 14;
pNtr = pNtr - iApples;
//*/
Notice the top section of code is commented-in (ie, will be compiled), but the bottom section is commented-out (ie, will be ignored). Now I can just remove a '//' and switch it round!
- Code:
// good code!
/* // REMOVED '//'
printf("elephants eat grass");
x = y * 14;
pNtr = pNtr + x;
/*/
printf("elephants don't eat grass");
y = x * 14;
pNtr = pNtr - iApples;
//*/
There. Simple.
Yes, it is a slow day