Error: std: out_of_range

0

The program consists of entering a word and filling an array with each letter of the word. However, this error does occur:

#include<iostream>
#include<string>
using namespace std;

int const TAM_MAX=5;

typedef enum{A,B,C,D,E}tLetra;
typedef tLetra tArray[TAM_MAX];


int main()
{
    tArray array;
    string palabra;
    char letra;
    cout << "Introduzca una palabra de 5 cifras:";
    cin >> palabra;
    for(int i=0; i<TAM_MAX; i++)
    {
        letra=palabra.at(i);
        if(letra=='a' || letra=='A')
        {
            array[i]=A;
        }
        else if(letra=='b' || letra=='B')
        {
            array[i]=B;
        }
        else if(letra=='c' || letra=='C')
        {
            array[i]=C;
        }
        else if(letra=='d' || letra=='D')
        {
            array[i]=D;
        }
        else if(letra=='e' || letra=='E')
        {
            array[i]=E;
        }
    }
    return 0;
}
    
asked by Vendetta 26.01.2018 в 17:22
source

0 answers