My source code for converting a hex string to decimal is :
// conversion hexa to decimal
{
char *temp;
UpdateData(TRUE);
m_dec = strtoul( m_hex, &temp, 16 );
UpdateData(FALSE);
}
m_hex is a editbox (CString)
and
m_dec is a editbox (long)
Anny number variables are binary. Theirs string representation can be binary, octal/decimal/hexadecimal. If you want to use strings, you can use sptintf for char*, operator<< for ostreams:
char* x[50];
fprintf(x,"dec-%d, hex \x%d",OneNumber,OneNumber);
do you see? you use the same OneNumber.
ostrstream xx;
xx<<"dec value "<<dec<<OneNumber<<endl<<"hex value "<<hex<<OneNumber<<flush; John Fill
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.