fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. const char wanted_rgb[] = "#1122334455"; // from another function
  6.  
  7. uint8_t r, g, b, time, something;
  8.  
  9. int result = sscanf( wanted_rgb, "#%2x%2x%2x%2x%2x", &r, &g, &b, &time, &something );
  10.  
  11. if ( result >= 3 )
  12. {
  13. printf( "r = 0x%2X g = 0x%2X b = 0x%2X ", r, g, b );
  14.  
  15. if ( result > 3 )
  16. {
  17. printf( "time = %d ", time );
  18. }
  19.  
  20. if ( result > 4 )
  21. {
  22. printf( "something = %d", something );
  23. }
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 5680KB
stdin
Standard input is empty
stdout
r = 0x11 g = 0x22 b = 0x33 time = 68 something = 85