Use:
#include <iostream>
...
std::cout << std::hex << a;
There are many other options to control the exact formatting of the output number, such as leading zeros and upper/lower case.
More Related Contents:
- How do you convert decimal in integer to hexadecimal in integer? [closed]
- Why uninitialized variable print a strange negative value? [duplicate]
- How do I print a double value with full precision using cout?
- C++ convert hex string to signed integer
- Why is address of char data not displayed?
- Converting a hex string to a byte array
- How to print Unicode character in C++?
- How can I pad an int with leading zeros when using cout
- Error “undefined reference to ‘std::cout'”
- C++ alignment when printing cout
- how do I print an unsigned char as hex in c++ using ostream?
- std::cout won’t print
- Why does streaming a char pointer to cout not print an address?
- How to make C++ cout not use scientific notation
- Hide user input on password prompt [duplicate]
- Why use hex?
- cout or printf which of the two has a faster execution speed C++?
- C++: Converting Hexadecimal to Decimal
- Why is std::cout not printing the correct value for my int8_t number?
- How to cout a float number with n decimal places [duplicate]
- What is the underlying type of a c++ enum?
- Getting hex through Cin
- C++ cout printing slowly
- When does cout flush?
- Using C++ to edit the registry
- Is std::cout buffered?
- Does std::cout have a return value?
- What is the difference between cout, cerr, clog of iostream header in c++? When to use which one?
- Why “cout” works weird for “unsigned char”?
- “cout” and “char address” [duplicate]