H
H
Haaaaz2022-04-07 12:17:16
C++ / C#
Haaaaz, 2022-04-07 12:17:16

Check first 2 bytes?

Hello. For example, there is a file, I open it. But how do I represent it in binary form so that I can read the first 2 bytes from it? To be specific, I need to compare the first 2 bytes with 0x4D 0x5A. Googled, but still did not understand how to convert the file that I receive through CreateFile () into an array of bytes

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Wataru, 2022-04-07
@haaaaz

Open the file in ifstream in binary mode and read 2 bytes with read .
Or use fread . Read 2 bytes into a buffer of length 2.

V
Vasily Bannikov, 2022-04-07
@vabka

https://stackoverflow.com/questions/5420317/readin...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question