在C语言中,我们通常会使用 scanf 和 printf 来对数据进行输入输出操作。虽然我们尽可能的保留stdio.h,在C++中用作cstdio,但是 C++ 又增加了一套新的、更容易使用的输入输出库。
C++使用iostream这样的头文件来作为输出输出头文件,iostream几乎涵盖了stdio.h所有的内容,并拓展了一些其他的应用。
C++使用更加高级的cout cin endl,这些都是对象。在std中命名。
![591cc236e15b32961d105da24b5de9ae.png](https://i-blog.csdnimg.cn/blog_migrate/3c638ee7b95f3eacd77ff96c8bd21578.png)
我们从一个简单地例子了解一下:
#include //输入输出头文件
using namespace std; //使用std命名空间
int main()
{
char arr[20];
cin>>temp;//输入任意内容
cout << "hello world" << endl; //输出"hello world"换行
return 0;
}
输入任意内容运行显示:hello world
在编写 C++ 程序时,如果需要使用输入输出时,则需要包含头文件iostream,