Thursday 7 May 2015

SIZE OF FILE

#include<iostream.h>
#include<process.h>
#include<fstream.h>
#include<conio.h>
int main()
{

char d[12]; cout<<"HIMANSHU SINGH\n";
cout<<"-Enter file name ";
cin.getline(d,12);
 ifstream fin;
 fin.open(d,ios::in);
 if(!fin)
 {cout<<"\n file not found ";
 exit(-1);
 }


fin.seekg(0,ios::end);                              or   ifstream fin(filename,ios::in|ios::ate);
 long bytes=fin.tellg();                                   long bytes=fin.tellg();
 cout<<"\n bytes= "<<(bytes);                      cout<<bytes;
 getch();
 return 0;
 }


                                                          file to be check- sizecal.txt
                                                                            
                                                                         output


No comments:

Post a Comment