코드 :fstream get (char *, int) 빈 줄을 어떻게 조작합니까? strfile.cpp에서
#include <fstream>
#include <iostream>
#include <assert.h>
#define SZ 100
using namespace std;
int main(){
char buf[SZ];
{
ifstream in("strfile.cpp");
assert(in);
ofstream out("strfile.out");
assert(out);
int i = 1;
while(!in.eof()){
if(in.get(buf, SZ))
int a = in.get();
else{
cout << buf << endl;
out << i++ << ": " << buf << endl;
continue;
}
cout << buf << endl;
out << i++ << ": " << buf << endl;
}
}
return 0;
}
나는 모든 파일 을 조작하려는
하지만 strfile.out에서 : 그 fstream.getline 알고
1: #include <fstream>
2: #include <iostream>
3: #include <assert.h>
4: ...(many empty line)
(숯불 *를, int)에이 기능 할 수 그것을 관리 할 수 있지만, 이것을 수행하는 방법을 알고 싶습니다. "fstream.get()"함수를 사용하십시오.
당신이 "어떻게 작동"무엇을 의미합니까? 빈 줄을 무시 하시겠습니까? 빈 줄에 코드가 없습니까? – user7116
불쌍한 영어에 대해 유감입니다. 빈 줄이 생기면 줄 번호로 출력하십시오. – lanmezhe
파일을 복사하고 각 줄 또는 100 자 이후에 줄 번호를 삽입하려는 경우 둘 중 먼저 발생하는 것입니다. 당신은 당신의 문제에 대해 더 구체적으로 말할 수 있습니까? – molbdnilo