0

Expanding my other question..

unsigned char* s_char = data + offset;
(*s_char) = size_t(((*s_char) & 0xf0)) | new_doff;

How to print s_char's bit representation?

Community
  • 1
  • 1
kagali-san
  • 2,964
  • 7
  • 48
  • 87
  • 1
    Possible duplicate of [Is there a printf converter to print in binary format?](http://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format) – peoro Jan 28 '11 at 19:57
  • Confirmed. Unfortunally, that question didn't came up in search. – kagali-san Jan 28 '11 at 20:02

2 Answers2

1

You'll need to manually print it using something like:

  printf("%d%d%d%d%d%d%d%d", *s_char & 0x80, *s_char & 0x40, ..., *s_char & 0x01);
Wes Hardaker
  • 21,735
  • 2
  • 38
  • 69
1

I would use a type cast to int like

unsigned char* s_char = data + offset;  
(*s_char) = size_t(((*s_char) & 0xf0)) | new_doff;  
int s_char_int;
s_char_int = (int)s_char;  

Then you can print it to the console or whatever else you want

Nate Koppenhaver
  • 1,676
  • 3
  • 21
  • 31