I'm not exactly sure where the illegal conversion is, but your code wouldn't work anyway, because gPacket is of type struct PACKET, so if you add 1 to it, you will actually add the length of the struct, not just one byte. This allows arrays of structs to easily be iterated over. I would do something like this: ... char *cp; cp = (char *) &gPacket; for (i=0; i<6; i++) { SCI_PrintByte(*cp++); } ... Regards, Simon. --- On Sat, Aug 10, 2002 at 11:09:55PM -0700, Donovan Parks wrote: > 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