problems with a string array, assistance please!

I'm pretty new to C++ (have done about 2 months on my course), and I've been trying to get this so that region will update itself through each loop cycle, but all i'm coming up with is errors:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
#include<fstream>
#include<string>
using namespace std;

int main()
{
	std::string region[4] = { "North" ; "Midlands" ; "South-East" ; "South-West" };
	int num =1;
	
	string candName[4];
	int candNum =1;
	int vote[4];
	int voteNum =1;


	do {
		cout << "Enter Name of Candidate:  ";
		cin >> candName[candNum] >>endl;
		do {
			cout << "Enter the votes for candidate from " << region[num] << ":  ";
			cin >> vote[voteNum];
			num++;
			voteNum++;
		} while (voteNum <5);
		candNum++;
	} while (candNum <5); 

}

Any help that can be given will be greatly appreciated; knowing me the problem is something stupidly simple...
Last edited on
Check the values of candNum in the loop.
When Initializing arrays use ',' to separate elements instead of ';'

You cannot use endl with cin. endl prints a newline ('\n') character. It can only be used with output (cout).

In c++ arrays begin from 0.
region[0] is "North"
region[3] is "South-West"
region[4] is ???
Initialize candNum to 0 instead and change the 'while' condition to candNum<4
And do the same with voteNum and num.
Thanks for the replies, sorted now
Topic archived. No new replies allowed.