fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. char str[] = "0,228,03,1771,2d6f,55,62";
  7.  
  8. const uint8_t MAX_TOKENS = 7;
  9. int32_t val[ MAX_TOKENS ];
  10. char *ptr;
  11.  
  12. for ( uint8_t i = 0; i < MAX_TOKENS; i++ )
  13. val[i] = strtol( ( i == 0 ) ? str : ptr+1, &ptr, ( i == 3 || i == 4 ) ? 16 : 10 );
  14.  
  15. for ( uint8_t i = 0; i < MAX_TOKENS; i++ )
  16. printf( "%d%c", val[i], ( i < MAX_TOKENS-1 ) ? ',' : '\0' );
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
0,228,3,6001,11631,55,62