开发者

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 su开发者_C百科ccessfully 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?


Why not use

#if 0
{code here, lots of it even nested /* */ }
#endif
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜