I have a simple dialog box containing two edit boxes, If a decimal number is entered into the first box I would like for the equivalent binary value to appear in the second box.
You could do it this way:
The "Decimal-Edit box" should get a variable type 'int',
the other type 'CString'.
When a button is clicked (or another message of your choice), do this:
Code:
void CYourDialog::OnMessage()
{
UpdateData();
char buffer[20]; //20 could take numbers up to 2^18(+\0)
_itoa(decimal_variable, buffer, 2)//2 indicates binary
strBinaryVariable= buffer;
UpdateData(FALSE);
}
This works; but it is not a very good code.
Eg. you have to look out that the decimal value is not negative etc.
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.