-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSession16B.cpp
More file actions
64 lines (41 loc) · 1.1 KB
/
Session16B.cpp
File metadata and controls
64 lines (41 loc) · 1.1 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
//fstream out("YourStudents.txt", ios::out | ios::app);
fstream out;
out.open("YourStudents.txt", ios::out | ios::app);
out<<"1, Mike, 20\n";
out<<"2, Leo, 22\n";
out<<"3, George, 25\n";
out.close(); // Releasing Memory
cout<<"Data Written in File\n";
/*
fstream in("YourStudents.txt", ios::in);
string line;
if(in.is_open()){
// getline function will return false if we have no other line to read in file
while(getline(in, line)){
cout<<line<<"\n";
}
}else{
cout<<"Sorry !! No Such File !!";
}
in.close();
*/
//fstream in("YourStudents.txt", ios::in | ios::out);
/*
// To Perform IO Operation as text
ios::out -> to write the data in file
ios::in -> to read the data from file
ios::app -> append the data
// To perform IO Operation as binary
ios::binary
image/audio/video
ios::ate -> at the end | Write Operation shall start from end of file
ios::trunc -> Truncate the data | Any content that exists in file before it is open are discarded
*/
return 0;
}