Hey guys!
Im having problems with a snippit of code ive written. I know this is basic C++ so its a little embarasing that i cant work it out myself. Ive googled the run time error message but im not 100% sure i understand what it means.
Unhandeled exeption, access violation
#ifndef SETTINGS_H
#define SETTINGS_H
#include<string>
#include<vector>
#include<iostream>
using namespace std;
class Settings
{
private:
vector<string>board;
protected:
public:
Settings();
bool loadAndDrawFont();
};
#endif
#include "Settings.h"
#include<allegro5\allegro.h>
#include<allegro5\allegro_native_dialog.h>
#include<allegro5\allegro_ttf.h>
#include<allegro5\allegro_font.h>
#include<iostream>
Settings::Settings()
{
board.push_back("050106007");
board.push_back("620054090");
board.push_back("000908002");
board.push_back("300000568");
board.push_back("080605020");
board.push_back("546000009");
board.push_back("700502000");
board.push_back("030840016");
board.push_back("800301040");
}
bool Settings::loadAndDrawFont()
{
//int blockSize = 36;
ALLEGRO_FONT *font = al_load_font("Assets/Fonts/Airmole Shaded.ttf", 36, NULL);
if(!font)//if the font didnt load
{
al_show_native_message_box(NULL, "Error Message", "Error", "Font not loaded", NULL, ALLEGRO_MESSAGEBOX_ERROR);
return -1;//end program
}
for(int i = 0; i < 9; i++)
{
for(int j = 0; j < 9; j++)
{
if(board[i][j] == ('1'))//this is the line thats the problem
{
al_draw_text(font, al_map_rgb(44, 117, 255), 100, 100, ALLEGRO_ALIGN_CENTRE, "1");
}
}
}