设为首页 加入收藏

TOP

1.3 AWord about Comments (2)
2013-10-07 16:15:07 来源: 作者: 【 】 浏览:78
Tags:1.3 AWord about Comments

Comment Pairs Do Not Nest

A comment that begins with /* ends with the next */. As a result, one comment pair cannot appear inside another. The compiler error messages that result from this kind of mistake can be mysterious and confusing. As an example, compile the following program on your system:

  1. /*  
  2. * comment pairs /* */ cannot nest.   
  3. * ‘‘cannot nest’’ is considered source code,   
  4. * as is the rest of the program   
  5. */   
  6. int main()   
  7. {   
  8. return 0;   

We often need to comment out a block of code during debugging. Because that code might contain nested comment pairs, the best way to comment a block of code is to insert single-line comments at the beginning of each line in the section we want to ignore:

  1. // /*   
  2. // * everything inside a single-line comment is ignored   
  3. // * including nested comment pairs   
  4. // */  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇2.2 Variables (4) 下一篇1.4 Flow of Control (2)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·数据库:推荐几款 Re (2025-12-25 12:17:11)
·如何最简单、通俗地 (2025-12-25 12:17:09)
·什么是Redis?为什么 (2025-12-25 12:17:06)
·对于一个想入坑Linux (2025-12-25 11:49:07)
·Linux 怎么读? (2025-12-25 11:49:04)