C++判断一个文件是否可以正确打开的代码
/* fopen example */ #include <iostream> #include <conio.h> using namespace std; int main() { FILE* fp; fp = fopen("C:/Users/Qin/Desktop/123.txt", "rb"); if ((fp == NULL)) { printf("\nerror on open C:/Users/Qin/Desktop/123.txt!"); _getch(); exit(1); } else { cout<<"the file C:/Users/Qin/Desktop/123.txt can be open correctly!" << endl; } system("pause"); return 0; }