fork download
  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include <ctype.h>
  4.  
  5. int main() {
  6.  
  7. char features[] = "0000000000b7011c0200000000000000";
  8.  
  9. uint8_t features_bytes[16];
  10. char * p = features;
  11. uint8_t i = 0;
  12.  
  13. while ( *p )
  14. {
  15. *p = toupper( *p );
  16. *(p+1) = toupper( *(p+1) );
  17. uint8_t highNibble = *p < '9' ? *p - '0' : *p - '7';
  18. uint8_t lowNibble = *(p+1) < '9' ? *(p+1) - '0' : *(p+1) - '7';
  19. features_bytes[i++] = ( highNibble << 4 ) | lowNibble;
  20. p += 2;
  21. }
  22.  
  23. for ( int j = 0; j < 16; j++ )
  24. printf( "%d\n", features_bytes[j] );
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 2740KB
stdin
Standard input is empty
stdout
0
0
0
0
0
183
1
28
2
0
0
0
0
0
0
0