fstream建立的对象open操作总是失败怎么办

#include <iostream>#include <fstream>using namespace std;void main(){ fstream file; file.open("d:尀尀mine.txt",ios::in||ios::trunc); if(!file) cout<<"文件打开错误"; file<<"hello c++"; file.close(); system("pause");}运行时总是返回 “文件打开错误”
2026年09月28日 02:41
有1个网友回答
网友(1):

请务必确认在 open 操作之前,d:\mine.txt 文件必须已经存在,否则 open 操作失败