fork download
  1. #include <iostream>
  2.  
  3. std::ostream& print_hex_to_stdout( int val, int width = 2 )
  4. {
  5. std::cout.width(width) ;
  6. std::cout.fill('0') ;
  7. return std::cout << std::hex << val ;
  8. }
  9.  
  10. int main()
  11. {
  12. //0d007b02
  13. int xx = 13, yy = 123, zz = 2 ;
  14. print_hex_to_stdout(xx) ;
  15. print_hex_to_stdout(yy,4) ;
  16. print_hex_to_stdout(zz) << '\n' ;
  17. }
  18.  
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
0d007b02