Thanks for the help to all those that replied. Lots of different solutions for me to choice from. Regards, Donovan > You've got the right idea. Here is a simple solution: > > for(i = 0; i < 6; i++) > SCI_PrintByte( ( (char *) &gPacket)[i] ); > > Bob Ammerman > RAm Systems > > > ----- Original Message ----- > From: "Donovan Parks" > To: > Sent: Sunday, August 11, 2002 2:09 AM > Subject: [PIC]: Hi-Tech C / C Question: Accessing Bytes in a struct > > > > Hello, > > > > I'm hoping there is a Hi-Tech C / C guru here that can give me a hand. > What > > I have is the following struct: > > > > struct PACKET // structure to hold incomming packets > > { > > BYTE packetLen; > > BYTE msgType; > > BYTE msgContents[MAX_CONTENTS_SIZE]; > > BYTE checksum; > > } gPacket={0, 0, {0}, 0}; > > > > Now, what I would like to do is print off each byte in this struct without > > having to access them using the "." operator. > > > > I can obviously do this: > > SCI_PrintByte(gPacket.packetLen); > > SCI_PrintByte(gPacket.msgType); > > ... > > ... > > > > But, what I am hoping for is something like: > > for(i = 0; i < 6; i++) > > SCI_PrintByte(*(&gPacket+i)); // this does not work! -> is > there > > something that will? > > > > > > &gPacket should give me the address of the gPacket structure and the "*" > > operator should then given me the value at that address. I receive a > > compiler error indicating I am going an "illegal conversion". Anyone? > > Thanks. > > > > Regards, > > Donovan Parks > > > > -- > > http://www.piclist.com hint: The list server can filter out subtopics > > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > > > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics