xcode写c++ Input file opening failed.

#include<iostream>#include<fstream>#include<cstdlib>#include<iomanip>usingnamespacest... #include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>

using namespace std;

void make_neat(ifstream& messy_file, ofstream& neat_file,
int number_after_decimalpoint, int field_width); // must be called by reference;

int main()
{
ifstream fin;
ofstream fout;

fin.open("rawdata.dat");
if(fin.fail())
{
cout<<"Input file opening failed.\n";
system("pause");
exit(1);
}

fout.open("neat.dat");
if(fout.fail())
{
cout<<"Onput file opening failed.\n";
system("pause");
exit(1);
}

make_neat(fin, fout, 5, 12);

fin.close();
fout.close();

cout<<"End of program.\n";
system("pause");
return 0;

}

void make_neat(ifstream& messy_file, ofstream& neat_file,
int number_after_decimalpoint, int field_width) // must be called by reference;
{
neat_file.setf(ios::fixed);
neat_file.setf(ios::showpoint);
neat_file.setf(ios::showpos);
neat_file.precision(number_after_decimalpoint);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.setf(ios::showpos);
cout.precision(number_after_decimalpoint);

double next;
while(messy_file >> next)
{
cout << setw(field_width) << next << endl;
neat_file << setw(field_width) << next << endl;

}

}

然后 rawdata.dat 里是
10.37 -9.89897
2.3131 -8.950 15.0

7.3333333333 92.8765
-1.237568432e2

我把这两个文件放到一起已经,为什么Xcode运行还是报错
Input file opening failed.
sh: pause: command not found
Program ended with exit code: 1
展开
 我来答
arongustc
科技发烧友

2017-03-25 · 智能家居/数码/手机/智能家电产品都懂点
知道大有可为答主
回答量:2.3万
采纳率:66%
帮助的人:6418万
展开全部
你具体错误没有打印,而仅仅打印input file opening failed是没有办法知道具体原因的
错误的原因可能有很多种,例如你文件名没有写全路径,因此也许你打开的文件不在你需要的位置
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式