hey i cant figure out whats wrong with this im getting errors that don't make sense to me, ill post the lines where the errors are and then ill post the program
int vote;
ifstream voter;
voter.open("ballot.txt");
voter>>vote;
while(voter.eof()){
voter>>vote;
it says theres like 7 errors in this thing
syntax error missing ; before '.'
missing type specifier
'voter' redefenition
syntax error missing ; before '.'
missing type specifier
'voter' redefenition
those 3 refer to the line
voter.open("ballot.txt");
missing ; before >>
missing type specifier
'voter' redefenition
those 3 refer to the line
voter>>vote;
syntax error 'while'
syntax error missing ; before '{'
missing function header
those 3 refer to the line
while(!voter.eof()){
2007-03-05
19:46:40
·
2 answers
·
asked by
Alex P
2
in
Computers & Internet
➔ Programming & Design
voter.close();
void print(int candidate1, int candidate2, int vote1, int vote2){
syntax error missing ; before '.'
missing type specifier
'voter' redefenition
syntax error '}'
missing ; before '}'
syntax error '}'
those refer to this line
voter.close();
the other one is pretty much the same, as you can see all of the errors are alike and i have no idea how to fix them because they don't make sense it seems to me that the code is right
2007-03-05
19:47:23 ·
update #1
here is the program itself:
#include
#include
using namespace std;
void tally(int&,int&,int&,int&,int&...
void print(int, int, int, int);
int main() {
cout<<"CS-114 Ballot Counter"<
int p1,p2,vp1,vp2,s1,s2,t1,t2,j1,j...
cout<
print(1, 2, p1, p2);
cout<
print(3, 4, vp1, vp2);
cout<
print(5, 6, s1, s2);
cout<
print(7, 8, t1, t2);
cout<
print(9, 10, j1, j2);
cout<
print(11, 12, sen1, sen2);
}
2007-03-05
19:48:20 ·
update #2
int vote;
ifstream voter;
voter.open("ballot.txt");
voter>>vote;
while(!voter.eof()){
voter>>vote;
if (vote==1){
p1+=1;}
if (vote==2){
p2+=1;}
if (vote==3){
vp1+=1;}
if (vote==4){
vp1+=1;}
if (vote==5){
s1+=1;}
if (vote==6){
s2+=1;}
if (vote==7){
t1+=1;}
if (vote==8){
t2+=1;}
if (vote==9){
j1+=1;}
if (vote==10){
j2+=1;}
if (vote==11){
sen1+=1;}
if (vote==12){
sen2+=1;}
if (vote==0){
p1+=0;}
}
voter.close();
}
void print(int candidate1, int candidate2, int vote1, int vote2){
if (candidate1==1&&candidate2==2)...
int p1=vote1, p2=vote2;
cout<<"President"<<'\t'<<'\t'<...
cout<<"Peter Parker"<<'\t'<<'\t'<p... !!!";
cout<
2007-03-05
19:48:44 ·
update #3
if (candidate1==3&&candidate2==4)...
int p3=vote1, p4=vote2;
cout<<" Vice President"<<'\t'<<'\t'<<"Votes...
cout<<"Clark Kent"<<'\t'<<'\t'<p... !!!";
cout<p... !!!"<
}
if (candidate1==5&&candidate2==6)...
int p5=vote1, p6=vote2;
cout<<"Secretary"<<'\t'<<'\t'<...
cout<<"Sue Storm"<<'\t'<<'\t'<p... !!!";
cout<p... !!!"<
}
if (candidate1==7&&candidate2==8)...
int p7=vote1, p8=vote2;
cout<<"Treasurer"<<'\t'<<'\t'<...
cout<<"Scott Summers"<<'\t'<<'\t'<
2007-03-05
19:49:15 ·
update #4
if (candidate1==9&&candidate2==10...
int p9=vote1, p10=vote2;
cout<<"Judge"<<'\t'<<'\t'<<'\t...
cout<<"Hal Jordan"<<'\t'<<'\t'<... !!!";
cout<
}
if (candidate1==11&&candidate2==1...
int p11=vote1, p12=vote2;
cout<<"Senator"<<'\t'<<'\t'<<'...
cout<<"Steve Rogers"<<'\t'<<'\t'<
cout<
}
cout<
}
3 hours ago
P.S. some of it got cut off but its pretty much repetitive, the errors come in the above text any help is appreciated
2007-03-05
19:49:49 ·
update #5