-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathc.cpp
41 lines (35 loc) · 814 Bytes
/
c.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
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
char str[100];
fstream stream("input.txt");
ifstream in("input.txt", ios::binary);
stream << "Lose\nYourself";
stream.flush();
/*
1| reads untill:
a| n-1 chars are reached.
b| eof is reached.
c| newline is reached. [\n is not extracted]
2| a null is added in str
*/
in.get(str, 100);
string s(str);
cout << s << "\n";
cout << "tellg:- " << in.tellg() << "\n";
in.seekg(0, ios::beg);
in.getline(str, 100);
s.assign(str);
cout << s << "\n";
cout << "tellg:- " << in.tellg() << "\n";
in.seekg(0, ios::beg);
in.get(str, 100, ',');
s.assign(str);
cout << s << "\n";
stream.close();
return 0;
}