#include <iostream>
#include <fstream>
#include <iomanip>
void readBytesFromFile(const std::string& filename, size_t startByte, size_t numBytes)
{
std::ifstream file(filename, std::ios::binary);
if (!file.is_open())
{
std::cerr << "Error: Unable to open the file." << std::endl;
return;
}
uint8_t* buffer = new uint8_t[numBytes];
file.seekg(startByte, std::ios_base::beg);
file.read(reinterpret_cast<char*>(buffer), numBytes);
size_t count = 0;
for (size_t i = 0; i < numBytes && file.good(); ++i)
{
std::cout << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(buffer[i]) << ' ';
++count;
if ((i % 10 == 0)) {
std::cout << std::endl;
}
}
delete[] buffer;
file.close();
}
int main() {
std::string filename = "D:/code/test.bin";
size_t startByte = 0;
size_t numBytes = 3500;
readBytesFromFile(filename, startByte, numBytes);
return 0;
}