Hi, I'm new to C++ and I'm trying to read various amounts of binary data from a file. I'm reading the first blockchain from BitCoin as an example. I need to read the first 4 bytes and output the answer "D9B4BEF9" to the screen. I can get an array in reverse order and show it on the screen.
Once I have that right I want to read the next 4 bytes, 80 bytes, etc. I'm using standard C++ simple programming so I can get an understanding of the code etc. I'm not using any OOP at the moment. There are examples on how to read blockchain data but I'm lost with it.
What I need is to format the output, and then to read the next set of data. That is all for now!
Line 20: This is an out of bounds reference. You only allocated 4 bytes (0-3). This null terminator is not needed anyway since you're printing the characters as hex values and not printing them as a C-string.
Other than that, your code looks likie it should be fine.
Thanks for the answer. Yes, that code works, but it is returning the values byte by byte. I just want a string out with the 4 bytes in the right order (answer must be: d9b4bef9) This value needs to be in a variable and not just printed out in a nice format.
Secondly, I want to read the next 4 bytes, get that value and then the next 80, etc...