I have a buffer of chars. I want to display them in a text box as hex. is there a simple way to do this? Thanks.

Recommended Answers

All 3 Replies

You could always use something like this....ofcourse you need to adapt it

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

using namespace std;

int main(void){
    
    ostringstream hello;
    
    hello << hex << (int)'A';
    cout << hello.str();
    
    cin.get();
    return 0;
}

Chris

what I want is something like this

char buffer[10];
buffer[0] = 0x5F;
TextBox->Text = buffer[0];

i need to cast or a function to convert or something that I dont know about to get the text box to display 0x5F or 5F. Thanks.

Can you not adpot what i gave you....or am i gonna have to spoon feed you?

ostringstream hello;
    char buffer[10];
    buffer[0] = 0x05;
    string blah;
    
    hello << hex << (int)buffer[0];
    
    blah = hello.str();
    TextBox->Text = blah;
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.