I am not very familiar with C, but I think ctoi means "character to integer", which is Ord() in Delphi. There is also a function called atoi which means "
ASCII to integer" (Delphi: StringToInt). Both return different results. In my opinion Ord() is the right function for your purpose.