1

Current convert decimal to hex in C#, i using code :

private string Dec2Hex(int value)
{
    return value.ToString("X2");
}

Please help port to C++ Jni. Thanks

Gioan Doan
  • 112
  • 8
  • [`snprintf`](http://en.cppreference.com/w/cpp/io/c/fprintf)? [`std::ostringstream`](http://en.cppreference.com/w/cpp/io/basic_ostringstream)? – Some programmer dude Sep 08 '15 at 09:13
  • 3
    possible duplicate of [Integer to hex string in C++](http://stackoverflow.com/questions/5100718/integer-to-hex-string-in-c) – marcinj Sep 08 '15 at 09:17

2 Answers2

2

so decimal to hex goes this way, if this helps you

std::stringstream ss;
ss<< std::hex << decimal_value;
std::string res ( ss.str() );
std::cout << res;
Matthias Burger
  • 5,549
  • 7
  • 49
  • 94
-1
int value = Convert.ToInt32(/*"HexValue"*/);
String hexRepresentation = Convert.ToString(value, 16);
Kinjal Gohil
  • 958
  • 9
  • 15