fork download
  1. #include<iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. ifstream fin("file_A.txt");
  8.  
  9. if(!fin){ cout << "讀檔失敗" << endl; } // 檢查讀檔成功與否
  10.  
  11. string s;
  12.  
  13. fin>> s ;
  14. // 或 getline(fin,s);
  15.  
  16. fin.close(); // 關閉檔案
  17. return 0;
  18. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
讀檔失敗