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

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++中多行注释是不允许嵌套的,因此推荐一律使用单行注释。

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