I've been trying to find a way to do this, but after hours of playing around i can't get it working..
I have a file that i want to read.. it's 1.5mb.. and contains data and strings.
So i open the file with an ifstream in binary mode, create a buffer, dump all data to it, then close the file. Now my buffer contains the file for searching..
however.. now i'm stuck in terms of how to search for a specific keyword.
this is what i have so far.
//Open our file
ifstream myFile(ourfile, ifstream::binary);
//get length of the file.
unsigned int length;
myFile.seekg(0, ios::end);
length = myFile.tellg();
myFile.seekg(0, ios::beg);
//create a buffer to hold the entire file
char *buffer = new char [length];
//read the file into our buffer
myFile.read(buffer,length);
//close the file as we don't need it anymore.
myFile.close();
I want to find a specific keyword's position in the buffer.
hopefully without looping every character.. like this..
Question
Bi0haZarD
I've been trying to find a way to do this, but after hours of playing around i can't get it working..
I have a file that i want to read.. it's 1.5mb.. and contains data and strings.
So i open the file with an ifstream in binary mode, create a buffer, dump all data to it, then close the file. Now my buffer contains the file for searching..
however.. now i'm stuck in terms of how to search for a specific keyword.
this is what i have so far.
I want to find a specific keyword's position in the buffer.
hopefully without looping every character.. like this..
(example)
"hello_cruel_world"
i don't want to have to search like this...
hello -> ello_ -> llo_c -> lo_cr -> o_cru -> _crue -> cruel
cruel == cruel.
Link to comment
Share on other sites
10 answers to this question
Recommended Posts