093. 파일을 한 줄씩 읽기(ifstream, get)

jychan99·2022년 1월 3일
0
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    ifstream read; //열기

    read.open("093.txt", ifstream::in); //파일이름, ifstream::in은 열기모드란의미.

    char line = read.get(); //한문자읽기.

    while (read.eof() == false) // eof는 end of file이란의미. 다읽을때까지 반복.
    {
        cout << line;
        line = read.get();
    }
    cout << endl;

    read.close(); //닫기

    return 0;
}
profile
내가 지금 두려워 하고 있는 일이 바로 내가 지금 해야 할 일이다. 🐍

0개의 댓글

관련 채용 정보