here's the code I have now:
How would I write the score to a file, and check if it's a new high score or not(least tries). I know you use the function ofstream, but I don't quite understand how to use it. Anothe rconcern is how might you prevent someone from editing the high score?Code:#include <iostream.h> #include <stdlib.h> #include <time.h> #include <conio.h> int rand(void); int main() { int tries; tries = 0; int num; int inputnum; srand(time(NULL)); num = rand()%101; cout<<"Pick a number between 0-100"<<endl; cin>>inputnum; tries++; bool loop = true; while( loop ) { if(inputnum == num) { cout<<"Your right! The number is "<<num<<". It took you "<<tries<<" tries."<<endl; getch(); return 0; } while(inputnum > num) { cout<<"Try a little lower."<<endl; cin>>inputnum; tries++; } while(inputnum < num) { cout<<"That's too low."<<endl; cin>>inputnum; tries++; } } return 0; }



LinkBack URL
About LinkBacks


