User Tools

Site Tools


c_-_c_files:file_size

C - C++ Files - File size

#include <iostream.h>
#include <fstream.h>
 
const char * filename = "test.txt";
 
int main () 
{
  long l,m;
  ifstream file (filename, ios::in|ios::binary);
 
  l = file.tellg();
 
  file.seekg (0, ios::end);
  m = file.tellg();
 
  file.close();
 
  cout << "size of " << filename;
 
  cout << " is " << (m-l) << " bytes.\n";
 
  return 0;
}
c_-_c_files/file_size.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki