Fixed the segment fault. Caused because I forgot to define the button array size and was mallocing into it, so I had a pointer but it wasn't really in the array or anything