精華區beta NTUBA92 關於我們 聯絡資訊
#include <fstream.h> #include <stdlib.h> const int MAXLENGTH = 21; // maximum file name length char file1[MAXLENGTH] = "prices.dat"; // place the file name up front int main() { ifstream in_file; in_file.open(file1); // open the file if (in_file.fail()) // check for successful open { cout << "\nThe file named " << file1 << " was not successfully opened" << "\n Please check that the file currently exists." << endl; exit(1); } cout << "\nThe file has been successfully opened for reading.\n"; return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.twbbs.org) ◆ From: ntumcc66.mba.ntu.edu.tw