Cast int to char

I am trying to initialise array of char by using the increment variable with cast.Why the code doesnt work
1
2
3
4
5
6
7
8
9
10
11
12

MyObj()
    {
        for(int i=0; i<10; i++)
           {
                array[i]=i+10;
                letters[i]=const_cast<char>(i+65);
           }

    }

For a something as simple as an integer to character cast don't use "const_cast". Just do this:
char C = 65; This will set the variable C to the character 'A'. Also, bookmark this: http://www.asciitable.com/
Topic archived. No new replies allowed.