Thanks for the ideas. I played around with them a little and here's what I'm looking at now. It's obviously incomplete as I have more candidates to add, but I just did a short version to see if it works before I add everyone. I seem to be getting errors, though, and I can't figure out why.
CODE
#include <stdio.h>
#define FILENAME "election2005.dat"
main(void)
{
int totvotes, dfrye, smcmillan, tknapp, ekolker, jsanders, sfrancis, mshelby, rrider, jledford, jbell, pshea, inva
lid, result = 0, power = 1, i;
char vote[13];
FILE *election2005;
election2005 = fopen("election2005.dat", "r");
if((election2005 = fopen(FILENAME, "r")) == NULL) {
printf("Error opening the file\n");
exit(1);
}
while(fscanf(election2005, "%s", vote) != EOF) {
for(i = 0; i<13, i++) // Line 58
{
if(str[i] == '1')
{
binary[i] = 1;
result += power;
}
power *= 2;
}
if (result = 4096) { // Line 67
dfrye++;
totvotes++;
}
else if (result = 2048) {
smcmillan++;
totvotes++;
}
else if (result = 1024) {
tknapp++;
totvotes++;
}
}
printf("Total votes: %d, for Donna %d, for smc %d for tknapp %d",totvotes, dfrye, smcmillan, tknapp); // Line 80
fclose(election2005);
exit(0);
}
What am I missing?
This post has been edited by goldenllama: 22 Oct, 2006 - 01:57 PM