User Profile
Collapse
-
I read in a binary file which is about 1/2 Gb to a char array. I then have to search for the first occurrance of 10101 or 111, that is the header of a message, what follows is the data of different size fields. I have found it too difficult, and cumbersome, to search for the pattern (using file.get())and then extract the fields as the pattern can start in any bit in a byte (for instance the lsb could be the start of the pattern 10101 but for the... -
Bit-by-bit Reading from Memory
How do you read a binary file in memory bit-by-bit?
ifstream file ("my.bin", ios::in|ios::bi nary|ios::ate);
if (file.is_open() )
{
size = file.tellg();
memblock = new char [size];
file.seekg (0, ios::beg);
file.read (memblock, size);
I was using file.get() but returns the next char I really want the next bit.
Any help is appreciated. :-) -
Pattern Search in Binary FIle
I have loaded a large binary file into memory and now I want to search for 10101. I was using file.get to return the next hex number and see if it was equal to 0x15. This is not correct as part of my seach pattern (10101) may straggle over two hex numbers.
Does anyone know of a way to find the pattern 10101 in a binary file loaded into memory?
Any help is appreciated.
No activity results to display
Show More
Leave a comment: