码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-09-23 15:02:23      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:stdio.h   hello   string   两种   div   turn   func   嵌套   UNC   

 

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] 注释

标签:stdio.h   hello   string   两种   div   turn   func   嵌套   UNC   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!