-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_io3.cpp
44 lines (38 loc) · 833 Bytes
/
file_io3.cpp
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
#include<fstream>
using namespace std;
int main() {
ofstream fout;
fout.open("abc",ios::app);
if(!fout){
cout<<"the file can not be opened!!"<<endl;
return 1;
}
char ch;
int line=0;
//write the characters
for (int i = 33; i < 128 ; i++)
{
cout.put((char)i);
}
fout.close();
//now display the content of the file
ifstream fin;
fin.open("abc",ios::in);
fin.seekg(0); //for restart the pointer from starting.
for ( int i = 33; i < 128; i++)
{
fin.get(ch);
cout<<" "<<i<<"=";
cout.put((char)i);
if(!(i%8)){
cout<<endl;
line++;
}
if(line>32){
system("PAUSE");
line=0;
}
}
return 0;
}