What's wrong with my C++ Quiz code

http://pastebin.com/gzfemmx8
That's the code,
So this is a quiz game
Alright so I made this quiz game using C++ for my school project and for some reason it bugs out when it comes to admin side like it displays some very high scores it doesn't display it properly.. please do run the program and check
It's nice and modular, every method has either text describing input or text describing output. The result is the code is very long and impossible to read.
You legit want us to read through 1967 lines of code? Debug your code to try and narrow it down.
You have to errors:

int quiz::gkscores()
{
cout<<"Final score is: "<<gkscore<<endl;
}
int quiz::mathscores()
{
cout<<"Final score is: "<<mathscore<<endl;
}

These functions need to return a value.
I have not looked at your code in detail, but checking where you read from and write to details.dat I can see that part of your problem is the lack of constructor for your quiz class, which means the members amount, total, gkscore, mathscore, option, i, a, and score are all uninitialized when you write the record to details.dat during registration.

You should also make fstreams s1 and s2 local rather than global variables and sort out their lifetimes.

Andy

PS And you should get rid of the C gets() function -- it's a bad idea to mix different IO libraries.
Last edited on
int main()
{
int x;
cin>>x;
cout<<x;
}
Topic archived. No new replies allowed.