Binary Files : Binary File « File « C++






Binary Files

  
#include <iostream>
using namespace std;  
#include <fstream>
int main () 
{
 long start,end;

 ifstream myfile ("test.txt", ios::in|ios::binary);
 start = myfile.tellg();
 myfile.seekg (0, ios::end);
 end = myfile.tellg();
 myfile.close();
 cout << "size of " << "test.txt";
 cout << " is " << (end-start) << " bytes.\n";
 return 0;
}
  
    
  








Related examples in the same category

1.Write numbers to a binary file and read them back
2.reading a complete binary file
3.seeks particular person in file
4.binary input and output with integers