求c++高手,帮我检查一个程序

来源:百度知道 编辑:UC知道 时间:2024/05/21 12:52:36
#include<iostream>
#include<fstream>
#include<vector>
#include<string>

using namespace std;

void main()
{
ifstream inFile("G:\\test.txt");
if(!inFile)
{
cout << "打不开你所指定的文件";
}

vector<string> s;

string a;

while(!inFile.eof())
{
inFile>> a;
s.push_back(a);

}
for(vector<string>::iterator it=s.begin();it!=s.end();++it)

cout << *it ;
cout << endl;

}
这个程序运行的话,总提示 cannot open Debug/read.exe for writing
那个高手能告诉我是什么原因

程序还有彻底关掉..
可能情况是你的ifstream在第一次执行之后没有释放,造成程序没有完全退出.所以以后再执行的话是无法读取这个exe的.因为它还在运行.应该是你的inFile忘记Close()了.

你程序 没正常关闭,建议任务管理器中,关掉进程 read。exe

你可能是把程序运行后,已经打开了运行后显示的那个窗口,但你没把窗口关了,就又运行程序,就会这样了

俺觉得你应该是编译时碰上这个错误吧,之前启动过后没有关,然后改了一点代码,直接点了执行,提示要编译一下,你点了确定,所以通不过。。。关了以前开的再编译。