1
지금은 파일을 복사하고 파일 이름에 파일의 내용을 출력하는 간단한 프로그램이있어서 ./file text.txt output.txt
을 입력하면 내용이 올바르게 복사되지만 생성됩니다 output.txt
의 끝에 새로운 줄을 추가하려고합니다. 사람이 왜, 어떻게다른 파일을 복사 할 때 새 파일에 새 행 만들기
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
ifstream fin;
fin.open(argv[1], ios::in);
ofstream fout;
fout.open(argv[2], ios::out);
char getChar;
while (!fin.eof())
{
fin.get(getChar);
fout << getChar;
}
fin.close();
fout.close();
return 0;
}
'ofstream'와'IOS :: out','ifstream'와'IOS :: in'을 ... 당신을 정말로 당신 도서관을 믿지 않아요, 그렇죠? –
'eof()'에 루핑하는 것이 보통 잘못되었습니다 : http://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-considered-wrong – Galik
@KerrekSB 무슨 뜻이야? .eof()는 파일의 끝까지를 의미합니다. 계속 읽으세요. –