Letters to Numbers with C++ chars -


say have char extracted string ( str.at(i) ), how convert char number such a=0, b=1, c=2... z=25? thanx in advance

assuming string in a-z range, char_value - 'a'.

this assumes letters consecutive. 'b' == 'a' + 1, 'c' == 'a' + 2, etc. in ascii, assumption correct.


Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -