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
Post a Comment