这个是我现在的程序, 但是每次打开z.txt 总是显示一个十六进制的字符串.
#include<iostream>#include<fstream>usingnamespacestd;intmain(){fstreamdataFile;dataFi...
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
fstream dataFile;
dataFile.open("z.txt",ios::in);
cout << dataFile;
dataFile.close();
return 0;
} 展开
#include <fstream>
using namespace std;
int main ()
{
fstream dataFile;
dataFile.open("z.txt",ios::in);
cout << dataFile;
dataFile.close();
return 0;
} 展开
展开全部
cout << dataFile;
==> 将fstream的Object直接打印出来,而不是打印文件z.txt的内容阿
try:
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
fstream dataFile;
char s[100] = {0};
dataFile.open("z.txt",ios::in);
dataFile.getline(s, 100);
cout << s;
dataFile.close();
return 0;
}
==> 将fstream的Object直接打印出来,而不是打印文件z.txt的内容阿
try:
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
fstream dataFile;
char s[100] = {0};
dataFile.open("z.txt",ios::in);
dataFile.getline(s, 100);
cout << s;
dataFile.close();
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询