I am working on a program which would really become easier to write if I can use character variables as an index to an array.. for eg. if char_var is a character variable say initialized to 'a'(ascii decimal value = 97), then array1[char_var] should refer to array1[97] element.
I wrote a snippet to test this
{
int array[200],i;
for (i=0;i<200;i++)
{
array[i]=i;
}
char c='a';
cout<<array[c];
getch();
}
It works the way I intend it to. However I was wondering if it could be compiler dependent in any way? also could you suggest any other way to write the code.I would like to avoid using atoi function. Thanks in advance !