如何忽略另一个多行注释里面的多行注释符号?
假设我想将整个代码放在注释中,以便我可以测试代码中的其他内容
/* This is my first comment */
printf("\n This is my first print command");
/* This is my second comment */
printf("\n This is my second print command");
如果我这样做
/*
/* This is my first comment */
printf("\n This is my first print command");
/* This is my second comment */
printf("\n This is my second print command");
*/
这是在制造错误。
最佳答案
您期望的是嵌套的多行注释。
直接引用标准C11
,章节§6.4.9,
Except within a character constant, a string literal, or a comment, the characters
/*
introduce a comment. The contents of such a comment are examined only to identify multibyte characters and to find the characters*/
that terminate it. 83)
和脚注,
83 ) Thus,
/* ... */
comments do not nest.
作为解决方法,您可以使用条件编译 block 作为
#if 0
.
.
.
.
#endif
将整个 block 注释掉。
关于C 编程 - 多行注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41138195/