Answer the question
In order to leave comments, you need to log in
How to display numbers of the same length in C++?
cout << std::hex << " " << num;
It is necessary that 8 digits be output.
That is, the number f23a87 was displayed as 00f23a87
Answer the question
In order to leave comments, you need to log in
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int num = 0xf23a87;
cout << hex << setfill('0') << setw(8) << num;
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question