Unhandled exception at 0x00000000710020BA (SDL2_ttf.dll)

Hi, I’ve been working on a small arcade game and I am now working on the score and the lives. When I try to edit the scoreboard to any number besides 0, I get this excpetion. Can someone give me an idea what is this reason for this error.

in the Graphics::init (). Initialize TTF_Init(); like this
if (TTF_Init() == -1) {

		printf("TTF Initialization Error: %s\n", TTF_GetError());
		return false;
	}

	//return true if no errors occurred during initialization
	return true;

PS: I do have the DLL’s, fonts and other files in the Debug folder.
Below is the code for how I print the score
void Scoreboard::Score(int score) {

ClearScore();

if (score == 0) {

	for (int i = 0; i < 2; i++) {

		mScore.push_back(new Texture("0","emulogic.ttf", 24, { 230,230,230 }));
		mScore[i]->Parent(this);
		mScore[i]->Pos(Vector2(-32.0f * i, 0.0f));
	}
}
else {
	std::string str = std::to_string(score);
	int lastIndex = str.length() - 1;

	for (int i = 0; i <= lastIndex; i++) {


		mScore.push_back(new Texture(str.substr(i, 1), "emulogic.tff", 24, { 230,230,230 }));
		mScore[i]->Parent(this);
		mScore[i]->Pos(Vector2(32.0f * (lastIndex - i), 0.0f));


	}
}

}

Forget it I resolved, thanks !

Would you mind sharing your solution in case anyone else runs in a similar problem? :slight_smile:

By the way, the best way to post code here is to enclose it in 3 backticks, like:

```c++
int main() {
	printf("Hello.\n");
	return 0;
}
```

which will then look like

int main() {
	printf("Hello.\n");
	return 0;
}

(the “c++” part makes discourse syntax-highlight your code as c++)

Yes, thank you! The solution was quite simple, sorry I noticed I misspelled it to “emulogic.tff”, while its actually should be"emulogic.ttf". Right here:
for (int i = 0; i <= lastIndex; i++) {

	mScore.push_back(new Texture(str.substr(i, 1), "emulogic.tff", 24, { 230,230,230 }));
	mScore[i]->Parent(this);
	mScore[i]->Pos(Vector2(32.0f * (lastIndex - i), 0.0f));

}
correct way:
for (int i = 0; i <= lastIndex; i++) {

	mScore.push_back(new Texture(str.substr(i, 1), "emulogic.ttf", 24, { 230,230,230 }));
	mScore[i]->Parent(this);
	mScore[i]->Pos(Vector2(32.0f * (lastIndex - i), 0.0f));


}

Sorry for wasting your time but thanks for responding

1 Like