ios - Convert some bytes from a unsigned char to int -
i want convert bytes int. code far:
unsigned char *byteptr = (unsigned char *)[ansdataframe];
i want take 4 bytes unsigned char: myframe[10]
, myframe[11]
, myframe[12]
, myframe[13]
, convert them integer.
int bytestoint(unsigned char* b, unsigned length) { int val = 0; int j = 0; (int = length-1; >= 0; --i) { val += (b[i] & 0xff) << (8*j); ++j; } return val; }
Comments
Post a Comment