Hi everyone I have the following function :
#define GET_BIT(p, n) ((((unsigned char *)p)[n/8] >> (n%8)) & 0x01)
void extractBit(void const * data, int bitIndex)
{
string result = "";
result.append(std::to_string(GET_BIT(data, bitIndex)));
}
and following link shows my bits which are pointed by void const* data
pointer :http://prntscr.com/3znmpz . void const* data
points the part of my screenshot which are represented by red box. (I mean first member is "00000000" shown in green box). If this is required information, my file is written and shown using by little endian.
With this function I want to append bit at bitset position into my result string
For example, when extractBit(data,23) I want to add first 1 in the red box into my result string but it gives me 0. Altough I've looked at my code through a couple hours, I could not find my mistake. Is there anyone to help me ?