C/C++ Debugging Tip

Words
70
Reading
1 min
Listen
Play
8y

I'm not sure when I discovered this, or if I've ever seen this posted anywhere, but this is a simple trick with multi-line comments I use when debugging code:

//*
Uncommented code
/*/
Commented code
//*/

To change this around, just remove the first /:

/*
Commented code
/*/
Uncommented code
//*/

What is going on is /*/ will always toggle commented to uncommented and vice versa. //*/ always ends a multi-line comment without causing a syntax error if there wasn't a multi-line comment before it.

C/C++ Debugging Tip | Ecency