1. #include <stdio.h>
  2. int main(void){
  3. /*
  4. *这是一个
  5. *多行注释
  6. */
  7. //这是一个单行注释
  8. printf("Hello World\n");
  9. return 0;
  10. }

注释

多行注释由/ /包括,上面代码多行注释中每一行开头的只是为了格式整齐,方便阅读。注意多行注释不能嵌套使用,如/嵌//使用/ ,C只会将 嵌/套 识别为注释,剩余的部分会报错。
单行注释由//开始。

转义字符

\‘ 单引号’(Single Quote或Apostrophe)
\“ 双引号”
\? 问号?(Question Mark)
\\ 反斜线\(Backslash)
\a 响铃(Alert或Bell)
\b 退格(Backspace)
\f 分页符(Form Feed)
\n 换行(Line Feed)
\r 回车(Carriage Return)
\t 水平制表符(Horizontal Tab)
\v 垂直制表符(Vertical Tab)

想要在字符串字面值表示/或”,必须使用//和/“ ,因为通常情况下/和”有特殊用途。
字符串字面值的空格也是一个字符,而在程序书写时空格和Tab往往对程序的正确性无关紧要,我们缩进和换行只是为了程序的可读性更好。例如:

  1. int main (void)
  2. {
  3. printf("Hello, world.\n");
  4. return 0;
  5. }
  1. #include<stdio.h>
  2. int main(void){printf("Hello, world.\n");return 0;}

这样的程序看起来让人血压上升,所以我们平时要注意养成良好的代码风格。