Hi, i am trying to make a general compression algorithm in c++ but i haven't really gotten the i/o part of this right yet. What i want to do somewhere along the line is to have my program parse say 10 or so characters at a time from a binary file which will then be processed with my compression algorithm and then outputted to another file. How would i go about correctly PARSING or just storing 10 bytes at a time to a certain string? Any help is appreciated. Thanks.
Code so far (this stores the entire file to a string but i don't want someone to go about compressing a 2GB file and not have enough memory to compress the file.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main (void)
{
ifstream infile("c:\\myfile.exe",ios::in|ios::binary);
string contents((istreambuf_iterator<char>(infile)),istreambuf_iterator<char>());
cout<<endl<<"contents stored to memory."<<endl;
system("pause");
return 0;
}