我试图将文件的内容打印到控制台,但它显示的是地址。请帮帮我(另外,请提出另一种方式而不是std::cout,因为我们在课堂上没有研究过,我不明白,但我想我应该使用它)。
这是代码:
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream f("board.txt");
if(f.is_open())
{
cout<<f;
}
else{
cout<<"ERROR:no file opened.";
}
}
Run Code Online (Sandbox Code Playgroud)