-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileHandle3.cpp
More file actions
26 lines (24 loc) · 770 Bytes
/
Copy pathfileHandle3.cpp
File metadata and controls
26 lines (24 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
//file handling seeg
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
system("cls");
// create an object of fstream
fstream file;
file.open("demo.txt");
cout<<"current position is "<<file.tellg()<<endl; //return cursor pointer positision index
cout<<(char)file.get()<<endl; //return the character ascii code
file.seekg(3);
cout<<"position is "<<file.tellg()<<endl; //returning index
cout<<(char)file.get()<<endl;
cout<<"position is "<<file.tellg()<<endl; //returning index
//reading character to the end
file.seekg(-3,ios_base::end);
cout<<"position is "<<file.tellg()<<endl; //returning index
cout<<(char)file.get()<<endl;
system("pause");
}