[問題] 寫入檔案和印在螢目的問題

看板C_and_CPP (C/C++)作者 (風樹)時間16年前 (2009/07/16 06:36), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
#include <iostream> #include <fstream> #include <cstring> using namespace std; int main() { ifstream fin("abc"); ofstream fout("def"); int c=0; char line[41]; while(fin.getline(line, 41)) { fout << line << endl; cout << strchr(line, 't') << endl; c++; } cout << c << endl; fin.close(); fout.close(); return 0; } def 的內容 = abc 不過沒有印出 c 的次數 而且測試發現回圈只跑一圈? strchr 也只搜第一行 請問這是怎麼回事? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.204.40.189
文章代碼(AID): #1ANbdhxh (C_and_CPP)
文章代碼(AID): #1ANbdhxh (C_and_CPP)