What's wrong with my C++ Quiz code

Dec 27, 2015 at 2:33pm
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
Dec 27, 2015 at 3:28pm
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.
Dec 27, 2015 at 3:44pm
You legit want us to read through 1967 lines of code? Debug your code to try and narrow it down.
Dec 27, 2015 at 8:49pm
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.
Dec 27, 2015 at 9:41pm
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 Dec 27, 2015 at 9:45pm
Dec 29, 2015 at 10:14am
int main()
{
int x;
cin>>x;
cout<<x;
}
Topic archived. No new replies allowed.