Program To Illustrate the Concept of File Pointers :
#include<iostream>
#include<fstream>
using namespace std;
main()
{
char data[50];
cout<<"Enter Text ";
cin.getline(data,50);
ofstream fout("file1.txt",ios::out);
fout<<data;
fout.close();
cout<<"\nOpening The File\n";
ifstream fin("file1.txt",ios::in);
fin.seekg(0,ios::end);
int x=fin.tellg();
cout<<"Total size "<<x<<" Bytes\n";
}
#include<iostream>
#include<fstream>
using namespace std;
main()
{
char data[50];
cout<<"Enter Text ";
cin.getline(data,50);
ofstream fout("file1.txt",ios::out);
fout<<data;
fout.close();
cout<<"\nOpening The File\n";
ifstream fin("file1.txt",ios::in);
fin.seekg(0,ios::end);
int x=fin.tellg();
cout<<"Total size "<<x<<" Bytes\n";
}
Output :