C++
파일 입출력
GOD03219
2018. 10. 2. 15:25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 |
#include<iostream>
#include<fstream>
using namespace std;
void main() {
char bu[30];
ofstream fon; //파일 출력 객체
fon.open("a.txt"); // 파일 오픈
fon << "zzㅋ"; // 파일에 "zzㅋ" 출력
fon.close(); // 파일 닫기
ifstream fin; // 파일 입력 객체
fin.open("a.txt");
fin >> bu; // 파일에 있는 값을 bu에 읽어오기
fin.close();
cout << bu;
} |
cs |