I did some research, and only c++ has unions and single-bit data structures. Now, through the demonic ingenuity of my thought processes, i recalled how i did the bit access.
All you do is put the char into char_bin_hex.ch and access the individual bits/dibits through char_bin_hex.bits.b1 etc and char_bin_hex.dibits.d1 etc.Code:union char_bin_hex { //edit: changed struct to union char ch; union char_to_bin bits; union char_to_hex dibits; } struct char_to_bin { //edit: changed union to struct unsigned b1: 1 unsigned b2: 1 unsigned b3: 1 unsigned b4: 1 unsigned b5: 1 unsigned b6: 1 unsigned b7: 1 unsigned b8: 1 } struct char_to_hex { //edit: changed union to struct unsigned d1: 2 unsigned d2: 2 unsigned d3: 2 unsigned d4: 2 }
Hope this helps! I will work on a function tht works with this when iget back frm church & lunch.
~Inquirer



LinkBack URL
About LinkBacks



