My server receives 6 bytes of data: 2 bytes of head and 1 variable consist of last 4 bytes in Big Endian order (in example below variable is 100000 decimal)
  00000001 head
  00000001
  10100000 start  4 bytes of variable (100000 decimal)
  10000110
  00000001
  00000000
I want to read this variable using this code below (buf contains data above)
 unsigned char buf[MAX_s]; 
 int32_t var = (buf[2] << 24) | (buf[3] << 16) | (buf[4] << 8) | buf[5];
 printf("  %u \n",var);
but expected result isn't 100000, but some other larger number. What i do wrong?
 
    