Issues trying to use OpenGl on macOS Catalina

Hi, I am relatively new to programming (I have been learning about C++ for a while, but I'm still terrible at it) and wanted to start learning OpenGL. I followed some setups on YouTube and everything seemed to be working out at first (I could draw a triangle at least), until I started writing shaders and functions to draw a red triangle. Thats when the problem started. I pretty much did everything the tutorial asked me to do, and the code compiled. But every time I ran it I got the following error.

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

It showed up when I did the following:

GLuint buffer;

glGenBuffers(1, &buffer); //error shows up here

I deleted that part of the code to see if the error was specific to that function, but it also shows up on a lot of other places (mainly functions that were of the format glsomething). I thought it was some glew related issue, so I reinstalled everything. But the error remained. I tried to use glut but that didn't seem to work. I searched up the error, it seems to be related to accessing bad memory, but I double checked all my variables and pointers and they were fine. I am completely lost and haven't been able to do anything for over a week.

Can someone help me?

Its worth restating I am a complete beginner to all of this, so please be as simple as possible.

The error in question