파일 입출력
파일 입출력
파일 모드
파일 쓰기
#include <iostream>
#include <fstream>
using namespace std;
int main() {
cout << "test.txt에 저장됩니다 (종료 :ctrl+z)" << endl;
ofstream fout;
fout.open("test.txt"); // open으로 파일을 연다
char ch;
while (cin.get(ch)) {
fout << ch;
}
fout.close(); // 파일 스트림을 다 쓰면 닫아야 한다.
return 0;
}파일 읽기
이진파일의 입출력
Last updated