I have a buffer like a char array, like this:
char buf[4]; buf[0] = 0x82; buf[1] = 0x7e; buf[2] = 0x01; buf[3] = 0x00;
Now, I would like to read char two and three together as an unsigned 16Bit integer in a large endian. How to do this using standard C (++) tools?
Currently, I only know the manual solution:
int length = but[3]; length += but[2] << 8;
This would be easy for 16Bit integers, but I would also need to parse 32Bit integers, which would make things a little complicated. So, is there a function from the standard lib library that does this for me?
Bodo
source share