C++stream中的open函数,调用它时如果没有这文件,它会不会自动创建一个

2026年09月23日 10:51
有1个网友回答
网友(1):

不会的~
你可以试一下~
最好判断一下文件是否成功打开~
cout<<"please input the filename:";
cin>>filename;
file.open(filename.c_str());
if(!file)
{
cerr<<"file open fail"< exit(-1);
}