#include <iostream>
#include <fstream>
using namespace std;
int main (int argc, char* argv[])
{
int length;
char * buffer;
string searchWord = argv[2];
string compareStr;
int searchSize = searchWord.size();
ifstream readFile;
readFile.open (argv[1], ios::in );
ofstream writeFile;
writeFile.open("newData.txt", ios::out);
readFile.seekg (0, ios::end);
length = readFile.tellg();
readFile.seekg (0, ios::beg);
buffer = new char [length];
while(!readFile.eof())
{
readFile.getline(buffer, length);
compareStr = "";
for (int i = 0; i < searchSize; ++i)
{
compareStr += buffer[i];
}
if (searchWord.compare(compareStr) == 0)
{
writeFile << buffer << "\n";
}
}
readFile.close();
writeFile.close();
delete[] buffer;
return 0;
}
I am running on Windows XP, and this program runs with test files (70 MB) just fine, but not with the much larger (1.5 GB) file. I get this error "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information."
Any help would be appreciated! Thanks! :)
-MissVaVaZoom