Mapping Characters to Ints
For my encryption assignment our professor wants specific values for characters rather than the normal ones that textpad or jedit uses (a=97, 2=50, /=47 etc)
Quote:
The mapping from character to integers is shown below:
0:'a' 1:'b' 2:'c' 3:'d' 4:'e' 5:'f' 6:'g' 7:'h'
8:'i' 9:'j'10:'k' 11:'l' 12:'m' 13:'n' 14:'o' 15:'p'
16:'q' 17:'r' 18:'s' 19:'t' 20:'u' 21:'v' 22:'w' 23:'x'
24:'y' 25:'z' 26:'A' 27:'B' 28:'C' 29:'D' 30:'E' 31:'F'
32:'G' 33:'H' 34:'I' 35:'J' 36:'K' 37:'L' 38:'M' 39:'N'
40:'O' 41:'P' 42:'Q' 43:'R' 44:'S' 45:'T' 46:'U' 47:'V'
48:'W' 49:'X' 50:'Y' 51:'Z' 52:'0' 53:'1' 54:'2' 55:'3'
56:'4' 57:'5' 58:'6' 59:'7' 60:'8' 61:'9' 62:' ' 63:','
64:'.' 65:'!' 66:'?' 67:']' 68:'[' 69:'*'
As you can see in the table above, the lower case letters are mapped to the integers 0 to 25, the upper
case letters are mapped to the integers 26 to 51, the decimal digits 0 to 9 are mapped to the integers 52
to 61 and the integers 62 to 69 represent some other printable characters.
it is suggested you write two functions:
// Given a character c, map it to its integer
// position as per the assignment spec
int mapCharToInt (char c )
// Given an integer i, map it to its character
// as per the assignment spec
char mapIntToChar (int i)
I'm not really sure how to even begin this, except to actually go through each character individually and assign it an integer value, and vice versa with integers to characters.
Thanks in advance.