#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
typedef unsigned char uint8_t;
/**
@brief Get a particular bit value from a byte
@param b [in] Any byte from which we want a bit value
@param p [in] Position of the bit in the byte [0..7]
@param n [in] Number of bits we want to get
@return The value corresponding the requested bits
*/
#define TAKE_N_BITS_FROM(b, p, n) (((b) >> (p)) & ((1 << (n)) - 1))
int main()
{
BYTE a = 2;
uint8_t buff[16];
buff[0] = 0x00;
buff[1] = 0x00;
buff[2] = 0xFF;
if (TAKE_N_BITS_FROM(buff[2], 4, 1) != 0) {
cout << "ewdsf" << endl;
}
system("pause");
return 0;
}