作者sunkill (风树)
看板C_and_CPP
标题[问题] 写入档案和印在萤目的问题
时间Thu Jul 16 06:36:23 2009
#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