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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -