How to ignore the multi-line comment symbols inside another multi-line comment?
Say I want to put the entire code in comments so that I can test other things in my code
/* 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");
If I do
/*
/* 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 creating error.
What you expect here is the multi-line comments to be nested.
Quoting directly from the standard C11
, chapter §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)
and the footnote,
83 ) Thus,
/* ... */
comments do not nest.
As a workaround, you can use the conditional compilation block as
#if 0
.
.
.
.
#endif
to have a whole block commented out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With