I need a function that returns the ASCII value of a character, including spaces, tabs, newlines, etc...
On a similar note, what is the function that converts between hexadecimal, decimal, and binary numbers?
char c; int ascii = (int) c; s2.data[j]=(char)count;
A char is an integer, no need for conversion functions.
Maybe you are looking for functions that display integers as a string - using hex, binary or decimal representations?
You don't need a function to get the ASCII value -- just convert to an integer by an (implicit) cast:
int x = 'A'; // x = 65 int y = '\t'; // x = 9
To convert a number to hexadecimal or decimal, you can use any of the members of the
char buffer; // make sure this is big enough! sprintf(buffer, "%d", 12345); // decimal: buffer is assigned "12345" sprintf(buffer, "%x", 12345); // hex: buffer is assigned "3039"
There is no built-in function to convert to binary; you'll have to roll your own.