我有一个文件要打印到屏幕上,但它返回的只是“0x28fe88”,而文件本身是 13 列乘以几百行。
#include <iostream>
#include <fstream>
#include <istream>
#include <ostream>
#include <cstdlib>
using namespace std;
int main()
{
//Opens .txt file
ifstream infile1;
infile1.open("Taylor.txt");
//Fail check
if(infile1.fail())
{
cout << "File failed to open.\n";
exit(1);
}
//Prints file to screen (not correctly)
cout << infile1;
//Closes file
infile1.close();
return 0;
}
否则我不会发布完整的代码,但我希望它足够短,不会引起抨击。