#include <iostream>

std::ostream& print_hex_to_stdout( int val, int width = 2 )
{
    std::cout.width(width) ;
    std::cout.fill('0') ;
    return std::cout << std::hex << val ;
}

int main()
{
    //0d007b02
    int xx = 13, yy = 123, zz = 2 ;
    print_hex_to_stdout(xx) ;
    print_hex_to_stdout(yy,4) ;
    print_hex_to_stdout(zz) << '\n' ;
}
