33,311
社区成员
发帖
与我相关
我的任务
分享
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
int i,a[5];
ofstream testFile;
testFile.open("test.dat");
if(!testFile)
{
cout<<"文件不存在"<<endl;
return;
}
for(i=0;i<5;i++)
testFile<<i<<" ";
testFile.close();
return 0;
}
#include <io.h>
#include <iostream>
using namespace std;
int main()
{
if(access("test.dat",0)==0)
cout<<"文件存在"<<endl;
else
cout<<"文件不存在"<<endl;
return 0;
}