9

I'm implementing a program in C++ using ifstream that must seek in large files (~1TB). However, this fails after reading 2GB. Is there a way to get file positions, even for large files? I compile for a 32-bit windows machine.

std::ifstream f;
f.open( filename.c_str(), std::ifstream::in | std::ifstream::binary );
while(true) {
    std::cout << (uint64_t)(f.tellg()) << std::endl;
    //read data
}
Timo
  • 5,125
  • 3
  • 23
  • 29
Patrik
  • 2,695
  • 1
  • 21
  • 36

1 Answers1

2

Since you are compiling on a 32-bit platform, if you use fstream, you are going to get 32-bits access. To access large files, you need to use a platform dependent solution :

BЈовић
  • 62,405
  • 41
  • 173
  • 273