我的文件输入与输出怎么打不开呢?
#include<iostream> #include<fstream> #include<string> #include<cstdlib> //#include"in_file" //#include"out_file"
using namespace std;
int main() { ofstream outfile; ifstream infile; infile.open("income.com"); outfile.open("tax.out"); if(!outfile) { cerr<<"error:unable to open output file!\n"; return -2; } if(!infile) { cerr<<"error:unable to open input file!\n"; return -1; }
string word; while(infile>>word) outfile<<word<<' '; infile.close(); outfile.close(); return 0; } 运行时总是说 unable to open input file 各位可否告诉我是怎么回事呢?