Access Violating Reading Location

For this I am basically just trying to print the letter A onto a window and I am getting the error posted. I am really not sure where to start with this one.
exception

#include
#include <SDL.h>
#include <SDL_ttf.h>

int main(int argc, char ** argv) {

bool exit_window_input = false;
SDL_Event event;

SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();

SDL_Window * window = SDL_CreateWindow("Sorting Algorithms Visualized", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0);
SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, 0);

TTF_Font * font = TTF_OpenFont("arial.ttf", 25);
SDL_Color color = { 255, 255, 255 };
SDL_Surface * surface = TTF_RenderText_Solid(font, "A", color);
SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface);

//loop forever waiting to quit
while (!exit_window_input) {

	SDL_WaitEvent(&event);

	switch (event.type) {

		//If the user presses the x (SDL_QUIT) the loop is broken
		case SDL_QUIT:
			exit_window_input = true;
			break;

	}

	//If it does not close display
	SDL_RenderCopy(renderer, texture, NULL, NULL);
	SDL_RenderPresent(renderer);

}

//close and shutdown the window, the renderer, and the program itself
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_DestroyTexture(texture);
SDL_FreeSurface(surface);
TTF_CloseFont(font);
SDL_Quit();

return 0;

}

You are not checking any returned values for NULL, so a crash is to be expected if anything is wrong. My guess is that you’ll find font is NULL, but you should be checking all the returned values (window, renderer, font, surface, texture) and reporting an error if any are NULL.

2 Likes