C语言中有单行注释(//
)和多行注释(/*....*/
)。
关于C语言中的注释,需要注意如下几点:
//
和/*....*/
不能代表注释符号/*....*/
多行注释不能被嵌套#include <stdio.h>
int main()
{
int/*...*/i;
char* s = "abcdefgh //hijklmn";
//Is it a \
valid comment?
in/*...*/t i;
return 0;
}
编译结果:
y=x/*p
代表什么意思?
本意:把x除以*p
的结果赋值给y。
编译器:将/*
作为一段注释的开始,把/*
后的内容都当成注释内容,直到*/
为止。
在编译器看来,注释和其他程序元素是平等的,因此作为工程师不能轻视注释。
#include <stdio.h>
int main()
{
int y = 1;
int x = 2;
int *p =&x;
y = x/*p;
return 0;
}
上面这段代码能编译过吗?
本文链接:http://so.lmcjl.com/news/23761/