c++代码框架解析
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
//把一个字符串插入到了输出流中
return 0;
}
iostream:
包含了关于输入输出语句的函数
- input==(i)==:输入
- output==(o)==:输出
关于头文件的引入:
- 可以用原来c语言的语法:#include <stdio.h>
- 可以用c++的语法:#include
- 去点==.h然后在前面加上c==就行
using namespace std
:使用命名空间std(标准命名空间)
- 命名空间为了避免起名冲突,比如:葬爱-王者,葬爱-小雨
cout << "Hello world!" << endl
:
cout
:输出流<<
:表示把hello World发送给cout打印endl
:可以理解为回车换行(相当于\n)
endl
和\n
的区别:
\n
:单纯回车换行endl
具有两重功能:
- 换行
- fflush(stdin):清空缓存