I'm getting this notification when I try to run my program.
Exception thrown at 0x50E6F1C0 (ucrtbased.dll) in CandidateVotes.exe: 0xC0000005: Access violation reading location 0x00000000.
Here's my code:
Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate's name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election.
void main()
{
string name[5] = { 0 };
int votes[5] = { 0 };
int total = 0;
for (int i = 0; i < 5; i++)
{
cout << "What is the name of Candidate number " << i + 1 << "?" << endl;
cin >> name[i];
cout << "How many votes did " << name[i] << " receive?" << endl;
cin >> votes[i];
total += votes[i];
cout << total << endl;
}
system("pause");
}