0

Hello..

I am using visual studio 2010 MFC.
in my programm i need to set 4 bit value in hex.

exaple:
i have hex value 64, it should desplay 0064
A = 000A
3E8 = 03E8

Is there any function in vc++, which set 0 ?

Thanks.

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by malvi
0

Well why not create your own function?

std::string HexToStr(const int value, int width)
{
	std::string hexStr;
	std::stringstream num;
	num.width(width);
	num.fill('0');
	num << std::fixed << std::hex << value;
	hexStr = "0x" + num.str();
	return hexStr;
}

Usage: std::cout << HexToStr(0x0004, 4);

Edited by nbaztec: n/a

0

Thanks for your answer.. It's really help full...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.