【发布时间】:2014-03-25 10:40:13
【问题描述】:
我给了一个任务,我需要从一个名为“filename.s”的文件中获取一些输入,我的代码应该将输出写入一个名为“filename.m”的文件。这是我的代码,但是当我尝试以 outfile.open(out); 身份打开文件时遇到编译问题
int main(int argc, char *argv[]){
readFile(argv);
int x=0;
compile(x);
mystring += "halt";
cout << mystring<< endl;
string out = argv[1];
out.resize(out.size()-1);
out += "m";
ofstream outfile;
outfile.open(out);
outfile << mystring;
outfile.close();
return 0;
}
有人知道可能是什么问题吗?因为当我给出这样的论点时它会编译:outfile.open("blah.m");thanks for your reply.
【问题讨论】:
-
我建议您先编辑代码并添加所有变量的声明。
-
你的意思是你有编译错误?在这种情况下,您应该编辑您的问题以包含完整且未经编辑的错误日志。
标签: c++ file input output ofstream