okay so I am trying this code. It is suppose to copy the data from my structure to a char array but why can't I get the same values for the last long long int position [7]?
Code:
struct packet
{
unsigned int type : 8;
unsigned int version : 8;
unsigned int length : 8;
unsigned int operand1 : 32;
unsigned int operand2 : 32;
unsigned int opcode : 7;
unsigned int flag : 1;
unsigned long long int result : 64;
};
struct packet newpacket ={5,2,3,50,32,33,1,2033};
unsigned char pbuffer[]={newpacket.type,newpacket.version, newpacket.length,newpacket.operand1,
newpacket.operand2, newpacket.opcode,newpacket.flag, newpacket.result };
printf("value of result is .. %u\n", pbuffer[0]);
printf("value of result is .. %u\n", pbuffer[1]);
printf("value of result is .. %u\n", pbuffer[2]);
printf("value of result is .. %u\n", pbuffer[3]);
printf("value of result is .. %u\n", pbuffer[4]);
printf("value of result is .. %u\n", pbuffer[5]);
printf("value of result is .. %u\n", pbuffer[6]);
printf("value of result is .. %d\n", pbuffer[7]);
printf("value of result is .. %llu\n", newpacket.result);