Hi,
Nice forum you have here. I think I'm going to like it. Now onto my problem:
I am trying to manipulate a Byte string, but first taking the string and putting it into Memory, then Parsing it. The problem is I cant seem to find the correct way to use the array and find the bytes I am looking for.
The following is the data in the "Log.txt" file that is referenced in my code:
Code:
48 40 20 00 39 40 7F 11 23 7C 57 BD A3 DB 80 D4 B5 D4 85 9A 3B 32 3B 2C 31 90 24 B0 23 01 91 0B 1E 79 02 41 82 07 00 06 42 00 01 B5 F9 03 33 42 00 03 62 0D 00 67 08 F7 EE 7E 8A 4C 76 CC 12 90 20
Now, What I am trying to do is take those bytes and parse it into this:
Code:
48 40 20 00 39
40
7F 11 23 7C 57 BD A3 DB 80 D4 B5 D4 85 9A 3B 32
3B 2C 31 90 24 B0 23 01 91 0B 1E 79 02 41 82 07
00 06 42 00 01 B5 F9 03 33 42 00 03 62 0D 00 67
08 F7 EE 7E 8A 4C 76 CC 12
90 20
Then Write it to the "Parsed.txt" file also referenced in my code.
I have been trying to get this down for the last 2 weeks now. I have been able to read and write from the log.txt to the parsed.txt file, but I cant get the parsing of the bytes down correctly. I have read books and nothing seems to point me to what I am looking for. Hopefully someone on here can help me with me problem.
Below is my code:
Code:
#include <fstream>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char filedata[200];
fstream obj1("Log.txt",ios::in|ios::binary);
fstream obj2("Parsed.txt",ios::out);
while(!obj1.eof()) {
obj1.getline(filedata,200);
obj2 << filedata << "\n";
}
obj1.close();
obj2.close();
return 0;
}