Good day to all, help me figure out how to read a bit field from a binary file? There is a structure written in C ++ Builder:
typedef struct { unsigned int nr:8; // unsigned int y:8; // 1 unsigned int sm:3; // 2 unsigned int d:5; // 3 unsigned int m:4; // 4 unsigned int r:4; // 5 } n_def; As I understand it, I first need to read the entire block and then break it into bits?
using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open))) { // пока не достигнут конец файла // считываем каждое значение из файла while (reader.PeekChar() > -1) { int numb = reader.ReadInt32(); uint nr = reader.ReadUInt32(); // переменная которую нужно разбить на биты } } In the second field, nr I already get not what I need. How to properly implement the task? can it be better to use another way of reading and writing to a binary file? thank you for your responses
Continuing the theme: Binary file , forgive me for posting on the exchanger just the file contains data from 2004.
And in VS the data is: nr = 1
y = 16 (matched)
sm = 2
ds = 15
ms = 11
rs = 0
