July 11th, 2003, 03:10 PM
VB's Asc(), Chr() functionality in C++
Does any one know of a function in C++ that is the same as Visual Basics Asc() and Chr(). I am converting a program and need something simialer. In VB Asc() converts an ascii character into its decimal value and Chr() then converts it back to the character. Thank you.
July 11th, 2003, 03:15 PM
You don't need them. A character can be used as a character or as a numeric value, that value being its ASCII code. And a number can be interpreted as a character.
For example, to convert a number 0..15 to a hex digit:
char hex = (num < 10) ? '0' + num : 'A' + (num - 10);
July 11th, 2003, 03:34 PM