Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commenting out C++ code, visual studio

I am testing a C++ source and I want to comment out some part of the code. There is a shortcut in Visual Studio: Ctrl+K and Ctrl+C for commenting and Ctrl+K and Ctrl+U for uncommenting the code. I can successfully comment out the code but uncommenting it will not be an "undo". It always removes some characters from the existed comment lines. Here is an example:

/*function 1 */
int func1()
{
    return 0;
}

If I want to comment out this code, I can apply Ctrl+K and Ctrl+C after selecting the code. And it becomes like this:

///*function 1 */
//int func1()
//{
//    return 0;
//}

If I want to un-comment the code, I should apply Ctrl+K and Ctrl+U after selecting it all. It becomes:

*function 1 */
int func1()
{
    return 0;
}

It removes an additional '/' and the old comment becomes corrupted. Is this a normal behavior or am I doing something wrong?

like image 981
delete_this_account Avatar asked Jun 16 '11 02:06

delete_this_account


1 Answers

Why not use

#if 0
{code here, lots of it even nested /* */ }
#endif
like image 129
Vinicius Kamakura Avatar answered Oct 01 '22 23:10

Vinicius Kamakura