title: C++: Saving a large binary file (2GB to 4GB) to RAM in a char*?
body: <p>I am working on a <strong>file transfer program</strong> in C++ which converts a file to binary, saves the bytes in a char*, then sends that char* through a <strong>TCP</strong> connection to another computer. The other computer then recreates the file locally. The program does work, but I run into a big problem with large files! I cannot allocate enough array indexes to contain the bytes! For example, if I want to send a 600MB file, I need a char* with 600 MILLION indexes. This works. But once I go any higher, the program simply cannot allocate the memory and I get errors.</p>
  
  <p>A friend of mine suggested that I split the file into chunks and do the transfer chunk by chunk, however this creates a plethora of other challenges and would require me to basically rewrite the entire program.</p>
  
  <p>Is there any way to get around this?</p>