Comments 注释简介

Let's take a quick break from programming and talk about comments.

Comments help programmers understand what exactly the computer program does.

Comments are also a short summary of your computer program.

让我们从编程中快速休息一下,来谈谈注释。

注释帮助程序员了解计算机程序的确切功能。

注释也是您的计算机程序的简短摘要。

There are two types of comments in programming:

  • Single line comment
  • Multiline comment

It is as simple as it sounds. Single line comment is used to comment a single line and Multiline comment is used for multiple lines.

The computer ignore these lines while executing a program.

编程中有两种类型的注释:

  • 单行注释。
  • 多行注释。

这听起来很简单。单行注释用于注释单行,多行注释用于多行。计算机在执行程序时忽略这些行

Single Line Comment 单行注释

Single Line Comment

Let's see how to comment your command

It's very simple, to comment any command you just have to put '//" symbol at the very beginning of your command

Once you put'//'at the beginning, whatever command or text you write in that entire line will be ignored.

Example:

单行注释。

让我们看看如何注释您的命令行。

这非常简单,要注释任何命令,您只需在命令的开头加上‘//’符号。

一旦您在开头加上‘//’,您在整行中编写的任何命令文本都将被忽略。

示例:

int main(){
// This line prints hi
printf("Hi");
}
  • Here, the comment "This line prints hi" will be ignored by the computer and it will just print 'Hi' on the screen.
  • Comments are extremely useful for other people to understand your code.
  • It also helps you to remember what your code does!
  • Whenever you think commenting would help in clarifying your code, do it!
  • 在这里,“此行打印Hi”的注释将被计算机忽略,它只会在屏幕上打印“Hi”。
  • 注释对于其他人理解您的代码非常有用。
  • 它还可以帮助您记住代码的作用!
  • 每当您认为注释有助于澄清您的代码时,就去注释吧!

What if you want the computer to ignore multiple commands written in multiple lines, like 12 commands?

It will be annoying to put '//' on each and every line, isn't it?

如果希望计算机忽略多行编写的多个命令,比如12行命令,该怎么办?

在每一行都加“//”会很烦人,不是吗?

Multiline Comment 多行注释

So there is a better way to comment multiple commands.

It's done by using '/' at the beginning of your first command and using '/' at the end of your last command.

This is called multi line comment.

Whatever you write between '/' and '/' , be it a command or any text, will be ignored by the computer.

因此,有一种更好的方法来注释多个命令。

这可以通过在第一个命令的开头使用‘/’,在最后一个命令的末尾使用‘/’来完成。

这称为多行注释。

无论您在‘/’和‘/’之间写什么,无论是命令还是任何文本,都将被计算机忽略。

Example 示例:

printf (" A ");
// printf "B");
printf (" C ");
/* printf (" D ");
print f (" E ");
printf (" F ");
*/

Here, the printf command for 'B' and printf command for 'D' to 'F" will be ignored by the computer, and you will not see these command's texts in the

The program 's output.

在这里,计算机将忽略‘B’的printf命令和‘D’到‘F’的printf命令,并且您不会在程序的输出中看到这些命令的文本内容。

图片知识总结

最新文章

  1. Redis 学习(二)
  2. Quartz.net 的简单使用,创建定时任务
  3. 深入理解java虚拟机(2)------垃圾收集器和内存分配策略
  4. 浏览器User-agent String里的历史故事
  5. KMP入门题目[不定期更新]
  6. hadoop启动守护进程报JAVA_HOME is not set and could not be found
  7. Spring Security(05)——异常信息本地化
  8. 一起学Android之ListView
  9. 基于YOLOv3和Qt5的车辆行人检测(C++版本)
  10. Unity中AB资源打包简单的脚本
  11. 如何安装使用FastReport
  12. js图的数据结构处理---弗洛伊德算法
  13. maven生命周期绑定要点
  14. ASP.NET自定义错误页并返回正确的500、404状态码
  15. Linux中断(interrupt)子系统之三:中断流控处理层【转】
  16. 初入android驱动开发之字符设备(四-中断)
  17. JSP复习(part 2 )
  18. 让浏览器识别HTML5规范中的新标签
  19. CF702F T-Shirts
  20. mysql字符集和字符排序

热门文章

  1. 多商铺平台手机电脑自适应宣传展示平台店铺javassh项目代码线上
  2. android开发之splash闪屏页判断是否第一次进入app代码
  3. 面向嵌入式的JavaScript引擎
  4. python笔记-dumps()与loads()的使用
  5. JAVA,.NET项目开发难上手?力软敏捷开发框架解君愁
  6. 小程序开发-微信小程序开发入门
  7. 用Python实现十大经典排序算法-插入、选择、快速、冒泡、归并等
  8. jackson读取json tree讲解
  9. ubuntu安装docker-ce 、docker-ce-cli、containerd.io
  10. AP、AC、无线路由器