-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path62_c_File_IO.cpp
More file actions
39 lines (30 loc) · 770 Bytes
/
62_c_File_IO.cpp
File metadata and controls
39 lines (30 loc) · 770 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
33
34
35
36
37
38
39
// File I/O in C++
// Using open() member functions...!!
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ofstream out;
out.open("sample.txt");
out << "This is Raj here!" << endl;
out << "Hello how are you" << endl;
out << "Doing CP now and then" << endl;
out.close();
// **********************************************************************************
ifstream in;
string st, st2;
in.open("sample.txt");
// in >> st;
// in >> st >> st2;
// getline(in, st);
while (in.eof() == 0)
// Means jab tak eof(end of file) na aa jaye tab tak print karte raho.
{
getline(in, st);
cout << st << endl;
}
in.close();
return 0;
}