首页 > 编程语言 > 详细

C/C++——[03] 注释

时间:2018-09-23 14:19:11      阅读:160      评论:0      收藏:0      [点我收藏+]

 

C/C++源程序中被注释的内容不能被编译,被认为是不属于程序的一部分。

C/C++的注释有两种写法:

  • 多行注释:以 “ /*”开头,以“ */”结尾:
    #include <stdio.h>
    
    /* main function
     print a "Hello World!" string to the stdout
    */
    int main(){
        printf("Hello World!");
        return 0;
    }

     

  • 单行注释:使用两个斜杠“ //”。从“ //”开始直到行末的内容,都是注释内容:
    #include <stdio.h>
    
    // main function
    // print a "Hello World!" string to the stdout
    int main(){
        printf("Hello World!");
        return 0;
    }

 

在C/C++中多行注释是不允许嵌套的,因此推荐一律使用单行注释。

 

C/C++——[03] 注释

原文:https://www.cnblogs.com/oddcat/p/9692500.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!