ifstream myfile("c:\\users\\94038\\desktop\\test_02\\string.txt", ios::in);
string ss;
while (getline(myfile, ss))
myfile.close();
getline函式是讀取一行,碰到換行符號\n停止讀取一行,然後下一次讀取在上次結束位置的下乙個開始(也就是下一行)。
ifstream myfile("c:\\users\\94038\\desktop\\test_02\\stack.txt", ios::in);
char c;
int t0 = 1;//t0是txt檔案的行數
while (myfile.get(c))
//cout << t0 << endl;
myfile.close();
io流檔案的讀取
在activity類中定義了openfileinput string name 跟openfileoutput string name,int mode 可以用來進行io流檔案的操作 而且缺省會儲存在記憶體卡當中,下面是 public class fileoperate extends activi...
C 中txt座標檔案的讀取
一 相關知識 1 容器vector的使用 需要 include以及using namepace std 2 結構體的使用 struct 3 檔案輸入流 需要 include 二 編寫 include include include include includeusing namespace std...
C 讀取txt檔案
1.逐行讀入 void readtxt string file ifstream infile infile.open file.data 將檔案流物件與檔案連線起來 assert infile.is open 若失敗,則輸出錯誤訊息,並終止程式執行 string s while getline i...