vector runtime error

whats the meaning of this error?

"vector subscript out of range".

The weird thing is that my vector worked then stopped working afterwards
It means you are trying to access a vector element that is out of range, e.g. when your vector has 3 elements you are trying to access the 4th - this will cause a runtime error.
It appears that you are trying to access a vector element that doesn't exist. Please post the code generating the error.
No need for him to post the code, just let your debugger run on the part that causes the error, look at the value of your index variable and the contents of your vector, and see how you can prevent that from happening - I trust bless can do that much on his own.
Basically, I'm trying to draw characters from my vector array, hence I'm passing the char * s. From "char s" I'm extracting a single character and then drawing it. Additionally the reason why I start from 32 is because thats the number the ascii values I use start from thus I have to subtract 52 to get my fonts.

1
2
3
4
5
6
7
8
9
10
11
12
void CFonts::DrawText(char *s, GLfloat gfText_PosX, GLfloat gfText_PosY, GLfloat gfFont_Size, GLfloat gfFont_Spacing)
{    
		
	//for loop drawing each letter
	for (int letter = 0;letter != strlen(s);letter++)
	{
	
	//draw font in array
		qva_Fonts[((int)*s)- 32]-> draw();
		s++;
	
	//loadmatrix Position & Scalling 
Does your qva_Fonts vector actually have that many elements? And why are you passing a char*? If you wanted to pass a string, you might as well have passed a std::string instead when you are already using C++. There is no real benefit to passing a char*. I also don't quite get why you are using a seperate counting variable here, considering you aren't even using it. What's more, if *s returns a char that's smaller than 32, you will have a negative index here...
Topic archived. No new replies allowed.