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.

Recommended Answers

All 2 Replies

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);

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.