c - C中双斜杠后的分号

标签 c comments

我有一个关于C语言注释的问题。
例如当我们写

//this is the first step

这意味着发表评论。

但是当我们写
//this is the first step;

这是否也意味着发表评论?我的意思是,当我们在双斜杠后添加分号时,这是否意味着程序的注释或主要部分?

最佳答案

双斜杠注释掉了行。编译器将忽略整行(包括分号,是)。

对于多行注释,或与某些代码在同一行注释,请在此处使用/ *注释* /

Wiki在这里有一些很好的信息:http://en.wikipedia.org/wiki/C_syntax#Comments

注意(来自Wiki):

C++ style line comments start with // and extend to the end of the line. This style of comment originated in BCPL and became valid C syntax in C99; it is not available in the original K&R C nor in ANSI C:

关于c - C中双斜杠后的分号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8780682/

相关文章:

复制字符串 - 如何处理内存泄漏和错误情况?

c# - 如何防止在 C#/* */comments 中按下回车星号

apache-poi - POI 3.17 在克隆工作表中创建单元格注释会产生不一致的 xlsx

c - C 中的多重链表

c - 在 Ubuntu 16.04 上找不到 printf.c

c# - C api 到 C# GUI

android - 比较 .yml 文件 OpenCV 中的图像 SIFT/SURF 细节?

c - 为什么我们不能将一个评论嵌套在另一个评论中?

c++ - 源代码注释的正则表达式

<script> block 中的 ASP.NET 服务器端注释