• CSE207 객체지향 강좌 및 C++ 관련, 누구나 묻고 답하는 게시판 입니다.
  • CSE207 수강생이 아니여도 편안하게 질문하세요.
  • 첨부화일은 이미지 화일 혹은 zip 화일로 업로드 하기를 권합니다.

제목lac7 응용 5번 질문입니다.2019-10-01 12:55
작성자

#include <iostream>

#include <string>

#include <fstream>

#include <iomanip>

using namespace std;


int main() {

int length, n, i;

char ch;


cout << "length = ";

cin >> length;


ifstream fin;

ofstream fout;


fin.open("input.txt");

fout.open("output.txt");


if (!fin) {

cout << "Error : no such file exists" << endl;

exit(100);

}


for (i = 1; fin; i++) {

for (n = 1; n <= length; n++) {

while (fin) {

fin.get(ch);

if (ch == '  ') n++; //ch가 줄바꿈문자이면 n++해라

fout << ch;

break;

}

}

n = 1;

fout << endl;

}


fin.close();

fout.close();

return 0;

}


코드를 이렇게 작성했는데 저 주석처리한 부분을 어떻게 구현할 수 있을까요?

댓글
이전LAB#7 응용3번 질문있습니다.2019-10-01
다음Example using Stream Flags2019-10-01