Error on string subsript range???

Error String subscript out of range of line 24.Don't know what exactly the error is. storeletterscore should be a number value of zero. Meanwhile, when zero is entered in that cout<<letters[store_letter_score][column]; which it does but gives me the error saying out of range. Why?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
enum alphbet {a,b};
	
void printoutusersentence ( string &usertypes)
{
	cout<<"\n\nType in a sentence: ";
	cin>>usertypes;
	int index=0;
	


	for (int column=0;column<5;column++)
	{
	//declare a variable to store in a character. Declare enum type variable to store in a value
	alphbet store_letter_score;
	char letterstore=usertypes[index];
	switch (letterstore)
	{
	case 'a':store_letter_score=a;
			break;
	case 'b':store_letter_score=b;
			break;
	
	}
	cout<<letters[store_letter_score][column];
	cout<<endl;
	index++;
	}

}


Also, this is my string images of two letters.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const string letters[46][5]=
{
	{				
"   _____   ",						
"  /  _  \\  ",
" /  /_\\  \\ ",
"/    |    \\",
"\\____|__  /" },


{"__________ ",
"\\______   \\",
 "|    |  _//",
" |    |   \\",
" |______  //"},
Last edited on
What if usertypes has less than 5 characters?
Last edited on
Oh crap :( please tell me I can use an if statement :( or some thing like if the next alphabet is a letter perform this loop
Topic archived. No new replies allowed.