【初识C语言】注释

1.注释的意义

(1)代码中有不需要的代码可以直接删除,也可以注释掉。
(2)有些代码比较难懂可以注释一下。

2.两种注释风格

2.1 C语言注释风格

/*xxxxxx*/ 一次可以注释一行或多行,但不能嵌套注释。
eg:

#include <stdio.h>

int main()
{
    
    
/*      printf("%Hello world!");
	/*printf("%Hello world!");
	printf("%Hello world!");*/
    	printf("%Hello world!");    */   //未被注释
    	
	return 0;
}

2.2 C++注释风格

//xxxxxxxx 一次可以注释一行或多行,可嵌套注释。
eg:

#include <stdio.h>

int main()
{
    
    
	//printf("%hello world!");
	//printf("%hello world!");
	//printf("%hello world!");
	//printf("%hello world!");

	return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_46630468/article/details/113406698