• 0

[C++] Decimal to hexadecimal fn


Question

2 answers to this question

Recommended Posts

  • 0
well, i want a C++ function that can convert number from decimal to hexadecimal

thanks in advance

584804123[/snapback]

You can also specify the base when you output to a stream.

#include <iostream>

using namespace std;

int main()
{
	int val = 25;
	string shex;

	hex(cout);
	cout << val << endl;
	dec(cout);
	cout << val << endl;
	cout << oct << val << endl;
	cout << dec << val << endl;

	return 0;
}

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.