c++的基本知识
1 #include <iostream> //iostream包含了输入输出语句 ,不能读成ios tream 2 #include <cstdio> //在c++中,以前c语言中所有的头文件都可以在前面加c使用 3 4 using namespace std; 5 /********************************** 6 * 使用std这个命名空间 7 * 命名空间我们可以理解成是游戏战队,可以有重复名字的成员, 8 * 但是我们使用的时候要提前标注所在命名空间 9 * 主要是为了命名使用的方便 10 *********************************/ 11 int main() 12 { 13 cout<<"hello world"<<endl; 14 15 16 //在标准的命名空间里面有一个cout(输出)对象,有一个endl(end line)对象 17 //如果我们省略使用命名空间那句语句我们就要这样写 18 19 // std::cout<<"hello world"<,std::endl; 20 21 //"<< "插入运算符 ,可以理解是将"helllo word"语句流入到cout输出到屏幕 22 23 //cout<<"hello"<<"world"<<endl; 这样写也是正确的语句 24 25 //"endl"做了两件事 1、换行 2、fflush(standin) 清空缓冲区 26 //"\n"就是很纯洁,只换行 27 //单独一个分号是一个空语句 28 //单行注释 29 30 31 printf("hello world\n"); //c语言中输出语句在c++中也是可以使用的 32 return 0; 33 }