Void function not printing

Hi, I have written a program that is supposed to output the results of an election between five candidates. The void function I have written to print the results is not printing anything when called. I am not receiving any compiler errors, and the rest of the program runs fine.

I am using Eclipse 3.8.0, with C++ add-on eclipse-cdt 8.1.0+dfsg-2, Ubuntu 12.04

declaration
 
void printResults(string candidates[], int canVotes[], int canIndex, int voteIndex, int totalVotes);


function call
 
printResults(candidates, canVotes, canIndex, voteIndex, totalVotes);


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void printResults(string candidates[], int canVotes[], int canIndex, int voteIndex, int totalVotes)
{
	setfill(' ');
	for (canIndex = 0; canIndex < 0; canIndex++)
	{
		cout << candidates[canIndex] << setw(25);

		for (voteIndex = 0; voteIndex < 5; voteIndex++)
		{
			double votePercent;
			cout << " " << canVotes[voteIndex] << setw(25)<< " ";
			votePercent = canVotes[voteIndex];
			votePercent = votePercent / totalVotes;
			cout << votePercent << "%" << endl;
		}
	}

}


Any hints about why this is not printing? If I put a "cout" after the function call in int main it prints it, just not anything from the void function.
for (canIndex = 0; canIndex < 0; canIndex++)
-Set canIndex equal to 0 every time
-Check if it is less than 0
-If less than 0, run the code and increment canIndex by 1

See any problems?
ah... yeah. It's not going to do anything with that loop condition. It's been a long day. Thank you so much for the quick reply!
Topic archived. No new replies allowed.