-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut60.cpp
More file actions
32 lines (25 loc) · 756 Bytes
/
tut60.cpp
File metadata and controls
32 lines (25 loc) · 756 Bytes
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
#include<iostream>
#include <fstream>
/*
The useful classes for working with files in C++ are:
1. fstreambase
2. ifstream--> derived from fstreambase
3. ofstream --> derived from fstreambase
*/
// In order work with files in c++, you will have to open it. Primarily, there are 2 ways to open a file:
// 1. Using the constructor
// 2. Using the member functions open()of the class
using namespace std;
int main(){
string st = " Harry bhai";
string st2;
// opening files using constructorb and writing it
// ofstream out ("sample60.txt");// Write operation
// out <<st;
// Opening files using constructor and reading it
ifstream in ( " sample60.txt");
// in >> st2;
getline( in, st2);
cout << st2;
return 0;
}