Question

I'm currently using C Builder:

DWORD finalAddress = 0xFFFFFFFF;
TListItem *ListIt;
ListIt->Caption = finalAddress;

This will output: 4294967295 (which is 0xFFFFFFFF in DEC)

I want it to show 0xFFFFFFFF.

How do I do that?

Was it helpful?

Solution

Assuming that you have access to C++ standard library, try this:

#include <sstream>
#include <iostream>
#include <string>

std::ostringstream ss;
ss << std::hex << finalAddress;

AnsiString ansiHex = AnsiString (ss.str().c_str());
ListIt->Caption = ansiHex;

This last assignment may not work - I do not have access to Embarcadero's headers, so I have no idea what's the type of ListIt->Caption. There may be need to perform additional conversion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top