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命令,并且您不会在程序的输出中看到这些命令的文本内容。

图片知识总结

03 Comments in C Programming C编程中的注释的更多相关文章

  1. lazy ideas in programming(编程中的惰性思想)

    lazy形容词,懒惰的,毫无疑问是一个贬义词.但是,对于计算机领域,lazy却是非常重要的优化思想:把任务推迟到必须的时刻,好处是避免重复计算,甚至不计算.本文的目的是抛砖引玉,总结一些编程中的laz ...

  2. shell中的输入输出和编程中的变量(shell 03)

    shell中的输入输出标准输入:键盘标准输出:终端显示器>> 追加是换行追加的echo -n 不尾随换行符 -e 启用解释反斜杠的转义功能 -E 禁用解释反斜杠的转义功能(默认) --he ...

  3. TCP/IP网络编程中socket的行为

    一. read/write的语义:为什么会阻塞? 先从write说起: #include <unistd.h>ssize_t write(int fd, const void *buf, ...

  4. Linux 编程中的API函数和系统调用的关系【转】

    转自:http://blog.chinaunix.net/uid-25968088-id-3426027.html 原文地址:Linux 编程中的API函数和系统调用的关系 作者:up哥小号 API: ...

  5. 浅谈TCP/IP网络编程中socket的行为

    我认为,想要熟练掌握Linux下的TCP/IP网络编程,至少有三个层面的知识需要熟悉: 1. TCP/IP协议(如连接的建立和终止.重传和确认.滑动窗口和拥塞控制等等) 2. Socket I/O系统 ...

  6. (转载)Linux 套接字编程中的 5 个隐患

    在 4.2 BSD UNIX® 操作系统中首次引入,Sockets API 现在是任何操作系统的标准特性.事实上,很难找到一种不支持 Sockets API 的现代语言.该 API 相当简单,但新的开 ...

  7. Cocoa编程中视图控制器与视图类详解

    iPhone编程规则是:一个窗口,多个视图.UIView是iPhone屏幕上很多控件的基础类.每个iPhone用户界面都是由显示在UIWindow(这其实也是个特殊的UIView)内的众多UIView ...

  8. 在 JNI 编程中避免内存泄漏

    JAVA 中的内存泄漏 JAVA 编程中的内存泄漏,从泄漏的内存位置角度可以分为两种:JVM 中 Java Heap 的内存泄漏:JVM 内存中 native memory 的内存泄漏. Java H ...

  9. 【转】资源文件在Delphi编程中的应用

    段东宁 计亚南 (郴州职业技术学院, 湖南 郴州  423000) 摘要: 资源文件是一种能有效地组织.管理和使用资源的文件形式,在软件开发中有着广泛的应用.本文详细介绍了在Delphi编程中资源文件 ...

随机推荐

  1. Redis秒杀实战-微信抢红包-秒杀库存,附案例源码(Jmeter压测)

    导读 前二天我写了一篇,Redis高级项目实战(点我直达),SpringBoot整合Redis附源码(点我直达),今天我们来做一下Redis秒杀系统的设计.当然啦,Redis基础知识还不过关的,先去加 ...

  2. Android Studio出现:Your project path contains non-ASCII 错误代码解决方法

    导入Project的出现: Error:(1, 0) Your project path contains non-ASCII characters. This will most likely ca ...

  3. Lua继承userdata

    http://blog.csdn.net/mywcyfl/article/details/37765751 http://blog.csdn.net/teng_ontheway/article/det ...

  4. github travis-ci持续部署hexo博客

    引言 目前我的博客源码是在coding上的,因为有很方便的持续部署,但是coding目前还不提供push文件的开放API. 因为最近做了一个一键分发平台,将博客分发到简书.CSDN等等的平台,但是我的 ...

  5. 12_进程,线程,协程,IO多路复用的区别

    1.进程 1.进程可以使用计算机多核 2.进程是资源分配的单位 3.进程的创建要比线程消耗更多的资源效率很低 4.进程空间独立,数据安全性跟好操作有专门的进程间通信方式 5.一个进程可以包含多个线程, ...

  6. github学生认证——申请学生开发包

    写在前面 申请学生认证的好处: GitHub学生的免费AWS Educate入门帐户,价值100美元. 专业的桌面IDE:IntelliJ IDEA,PyCharm等.学生的免费订阅,每年更新一次. ...

  7. Oracle中真正稳妥的求三甲的方法

    坐地铁回家路上忽然想起,三甲排名可能为多个,只取三名岂不荒谬.不信请看下面数据: create table tb_score( id number(4,0) primary key, name nva ...

  8. MySQL通过实体经纬度字段插入数据库point类型的经纬度字段

    说明:数据库:表中没有经度跟纬度字段,只有location字段(point类型) POINT(经度 纬度)实体类:只有经度 lng 字段.纬度 lat 字段 没有location字段 <!--添 ...

  9. Kubernetes中资源清单与Pod的生命周期(二)

    一.资源清单 1,定义: 在k8s中一般使用yaml格式的文件来创建符合我们预期的资源,这样的yaml被称为资源清单. 使用资源清单创建Pod: kubectl apply -f nginx.yaml ...

  10. shell 设置进程数运行

    问题描述 在服务器上提交任务时,需要限制运行的核的数目.程序本身是单线程的,但是不同的输入参数需要跑很多组,粗暴的方法是开多个终端,不断地去提交任务.但这比较麻烦,可以用 shell 实现. 基础 首 ...