What you could do is extract each line into a std::vector, where each element is of type std::string. The beauty of std::strings is that they allow easy manipulation of their contents.
So, here's how I would lay it out:
1) Extract an entire line into a std::string with std::getline( ).
2) Add the string to a vector.
3) When all extraction operations are done, search for "dc.b".
4) Once found (if found), do such and such to that line.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <stdio.h>
usingnamespace std;
int main (){
vector<string> data;
string txt = "";
fstream inFile;
inFile.open ("source.txt");
while(!inFile.eof())
{ getline(inFile,txt);
string key = "dc.b";
int found = -0x1;
found = txt.rfind(key);
if (found != -0x1){
data.push_back(txt);}
}
return 0;
}
This basically puts anything with "dc.b" in it into the vector and discarding any redundant data. Now my problem is what do i use to extract the 5 bytes from each element.