I've been working on plurality for hours now and I'm stuck with a "segmentaion error." So my approach to this problem was to sort the candidate objects in terms of votes and print the first object (which has the highest votes). If there were equal votes, I created another object array called equals[] and stored the two objects from candidates[] to that object. However, when I print this at the end, it returns a segmentation error after correctly printing out the results.

I know that the error lies somewhere in me printing too many things into equals[] but I don't understand how I can fix this.

Source code:

https://github.com/dhrubhagat-singh/plurality-cs50/blob/master/plurality.c