0

I ran check50 on my code and it worked fine on everything except in dealing with invalid votes, so I tested it by debugging and fount out that a segmentation error occurs while debugging, and then everything stops, I can't fully understand the error to deal with it correctly.

These are screenshots of the vote function and the error.

enter image description here

enter image description here

2
  • I 've searched the error and found out that it is accomplished when using a piece of memory that doesn't belong to me, which I don't think I 'm doing in my code, I 'm just comparing two given names. Jul 1 at 2:20
  • Please clarify if I have any misunderstanding. Jul 1 at 2:20
1

It should not seg fault if the election has 9 candidates. Remember 9 is the maximum number of candidates. Any election with fewer will seg fault in the vote function for loop. The loop should only process the number of candidates in the race. There is a variable created in the distro code that can be used to limit the loop.

1
  • Extremely helpful, Thanks so much. Jul 1 at 23:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .