I would like to convert a char to its ASCII int value.
I could fill an array with all possible values and compare to that, but it doesn't seems right to me. I would like something like
char mychar = "k"
public int ASCItranslate(char c)
return c
ASCItranslate(k) // >> Should return 107 as that is the ASCII value of 'k'.
The point is atoi()
won't work here as it is for readable numbers only.
It won't do anything with spaces (ASCII 32).
return c;
? – Kiril Kirov Apr 14 '13 at 12:57char mychar = "k"
: Oh heavens, have you tried this?"k"
is a null-terminated string, not achar
. Also,C++
statements have to end with a semi-colon. Surely you know this? – TonyK Apr 14 '13 at 13:04