Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Any way to map a set of password character symbols to a Boolean array in c++?

I'm developing a version of Hangman game called Password Hangman in c++, where I map the simple and capital alphabetical characters to a Boolean array so that i can know if that character is guessed or not. so far so good. Now I have no idea how to map the special characters that are allowed in a password to the Boolean array. This is the code in the Function:

 int PassHangman::letterToStoragePosition(char c) const
   {
        int posi;

        if(c>='a' && c<='z')
        posi = c - 'a';
        else
        if(c>='A' && c<='Z')
            posi = (c - 'A') + 26;
        else
        if(c>='0' && c<='9')
        {
            switch(c)
            {
                case '0':
                    posi = 52;
                    break;
                case '1':
                    posi = 53;
                    break;
                case '2':
                    posi = 54;
                    break;
                case '3':
                    posi = 55;
                    break;
                case '4':
                    posi = 56;
                    break;
                case '5':
                    posi = 57;
                    break;
                case '6':
                    posi = 58;
                    break;
                case '7':
                    posi = 59;
                    break;
                case '8':
                    posi = 60;
                    break;
                case '9':
                    posi = 61;
                    break;
            }
        }

    else
        posi = -1;


    return posi;        

   }

Comments