We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I would like to work on a simple communication buffer array abBuf[6][7], that contains all kind of data (8 and 16bit and string) directly without type conversions etc. Example: I have a 16byte variable X stored at abBuf[3][1] and abBuf[3][2]. The order (big endian) corresponds to a normal unsigned int variable. Is there a sort of elegant typecast or definition in C possible that would allow me to printf(%u,???) or use its value as 16bit variable in a formula etc besides the definition of a big union? Werner
What's wrong with a union - that's the natural way to do it! It wouldn't have to be one huge union - you could make an 8/16-bit union (or whatever), and have an array of them. Or try putting "htons" into your favourite internet search engine.
You could do this: printf("%u",*(unsigned int *)&abBuf[3][1]); Stefan
Thanks Stefan