[問題] 寫入檔案和印在螢目的問題
#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
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章