What i am trying to build is a simple program that can count votes during an election.
The program should first ask how many the candidates are and then create a candNUMB list. After, program asks to specify each candidate name, which should be added to the respective list. ex:
candidate n1: Paul
candidate n2: Frank
candidate n3: John
now that we have 3 lists the program should repeatedly ask for your vote (until you say stop), and then add the votes to each list (Paul, Frank, John). Eventually the program prints the result.
Debug shows candidate[candNUMB] not declared in this scope. What am I missing?
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int candNUMB = 0;
int candidate[candNUMB] = {0};
cout << "I can count votes during an election. Try me." << endl << endl;
cout << "Let's start. Specify the number of candidates: ";
cin >> candNUMB;
cout << endl << "There are " << candNUMB << " candidates. Specify each name." << endl;
for (int i = 0; i < candNUMB; i++)
{
cout << "Insert candidate n*" << i + 1 << " name: ";
cin >> candidate[i];
}
return 0;
}
EDIT: added int candNUMB = 0;
now the program won't start at all.
Process Returned -107374ecc