{
cand = canddts[8];
chkqu = chkq(chkqu, cand);
if (chkqu == 1)
{
clrg();
continue;
}
shwvte(cand);
t++;
candi9++;
continue;
}
if ((GetAsyncKeyState(VK_MENU)) && (GetAsyncKeyState(VK_BACK)))
{
y = 0;
for(int x = 1; x <= 9; x++) //defines the number of "slots" available in the vector
{
y++;
write.push_back(0);
}
//writes the results to a vector so we can exclude results of zero
write[0] = candi1;
write[1] = candi2;
write[2] = candi3;
write[3] = candi4;
write[4] = candi5;
write[5] = candi6;
write[6] = candi7;
write[7] = candi8;
write[8] = candi9;
//we are saving the amount of results to a file
ofstream sve;
sve.open("votes.txt", ios::out);
y = -1;
for(int x = 1; x < count; x++)
{
y++;
res = write[y];
sve<< res<< endl;
}
sve.close();
y = 0;
y1 = -1;
ofstream r;
r.open("resl.txt",ios::out);
r<< "__________________________________________________________"<< endl;
r<< " RESULTS"<< endl;
r<< endl;
for(int x = 1; x < count; x++)
{
y++;
y1++;
cand = canddts[y1];
res = write[y1];
r<< y<< "- "<< cand<< ": "<< res<< endl;
}
r<< "________________________________"<< endl;
r<< endl;
r<< "Total votes: "<< t<< endl;
r.close();
system("CLS");
return 0;
}
}
}
int namecand()
{
Sleep(5);
while(_kbhit()) _getch();
vector<string> candi;
string txt;
system("CLS");
int numcans, y, c;
string cand, v;
system("CLS");
cout<< "How many candidates? ";
c = -1;
y = 0;
while((c == -1) || (c > 9)) // makes sure the user doesnt input an invalid number
{
cin>> c;
}
cout<< endl;
for(int x = 1; x <= c; x++) // gets user input from the first to the last candidate
{
system("CLS");
y++; // allows to call candidates by a number
cand = "";
cout<< "Name of Candidate "<< y<< ": ";
while(cand == "")
{
getline(cin, cand); // makes sure that the program actually gets the line
}
candi.push_back(cand);
}
ofstream can;
can.open("candidates.txt", ios::out);
y = -1;
for(int ex = 1; ex <= c; ex++)
{
y++;
v = candi[y];
can<< v<< endl;
}
can.close();
system("CLS");
cout<< "Candidates successfully added!"<< endl;
cout<< "press ENTER to continue"<< endl;
cin.get();
system("CLS");
return 0;
}
int shw()
{
system("CLS");
string txt;
int q, y;
y = 0;
q = 0;
ifstream i;
i.open("resl.txt", ios::in);
if (i.is_open())
{
q = 1;
}
if (q == 1)
{
while(!i.eof())
{
y++;
getline(i, txt);
if ((txt == "") && (y == 1))
{
system("CLS");
q = 0;
break;
}
cout<< txt<< endl;
}
i.close();
}
if (q == 0)
{
return 0;
}
cout<< endl;
cout<< endl;
system("PAUSE");
system("CLS");
return 0;
}
int chksave()
{
int i, x, save;
char ch;
save = 0;
i = 0;
x = 0;
string txt;
ifstream s;
s.open("resl.txt", ios::in);
if(s.is_open())
{
i = 1;
}
if (i == 0)
{
system("CLS");
return 0;
}
if (i == 1)
{
getline(s, txt);
if ((txt == "saved") || (txt == ""))
And your question is? You've posted a whole lot of poorly formatted code with without indicating what we're looking for. Kinda' like a blind man in the Amazon.
My government teacher is holding a ballet and so i offered to write this program for him. We will be recieving 1000+ votes, so you can imagine his previous ways of doing this (tallying the votes and counting them out) were a bit strenuous. As a beginner, i decided to post this query: are there any suggestions you have that would make this program better than it is? If so, how? Would you mind explaining it for me (and/or giving me an example)? Thank you for your time, i look forward to your submissions!
I just want your suggestions on improvements i can make...
also:
@helios
If i wanted your criticism, I would have asked for it. Insulting a beginner is like insulting an animal because it doesn't understand what you're saying. I've not exactly "mastered" C++, if you haven't realized it yet. So, please discard your OPINION of my post and answer my question, or please refrain from posting anything at all. My understanding is that this thread is completely valid in this forum section, so please tell me if it is not.
First, when posting you should make sure you put code tags around your code. Just skimming through your code (there's too much for me to bother reading through) I notticed you have some really odly named functions like clrg, chkq and shwvte. They should be named something more descriptive.
My understanding is that this thread is completely valid in this forum section, so please tell me if it is not.
Okay.
1. Don't post post thousands of lines of code without any formatting. I can't believe this even needs to be said.
2. Don't post thousands of lines of code without some sort of introduction.
3. It's unreasonable to ask for suggestions about such a large amount of code. No one will read through the whole thing. Your naming conventions don't make it any easier or compelling, either.
Im sorry that i'm a beginner, but at least i'm admitting that. Also, next time i do this, i will post an intro before the code. I hope your next post has somthing usful to offer to me... your criticism isn't doing anything to accelarate my programming skills.