here is the problem code:
Code:
int SNum = long randomGet(long 100); //SECRET NUMBER
Here is my entire source:
Code:
//THIS PROGRAM WAS MADE BY NATHAN KRYGIER ON 2/1/05 AT 9:05 PM EST
//LINK TO LIBRARYS
#include <iostream>
#include <random.h>
using namespace std;
//DECALRE MAIN FUNCTION
int main(void)
{
//DECLARE VARIABLES
const int MaxVal = 100; //MAXIMUM VALUE IS 100
const int Minval = 0; //MINIMUM VALUE IS 0
int SNum = long randomGet(long 100); //SECRET NUMBER
int Guess; //USERS GUESS
int Sent=0; //END GUESSING SECTION
int Guesses = 0; //NUMBER OF GUESSES
char* Again; //PLAY ANOTHER GAME?
//GIVE GAME INSTRUCTIONS
cout<<"Guess a number between 1 and 100.\n"<< endl;
cout<<"If you decide you would like to give up guessing, enter the number 0."<< endl;
cout<<"\nYou have unlimited guesses."<< endl;
cout<<"\nPress enter to begin.\n\n"<< endl;
cin.get();//WAIT FOR USER TO PRESS RETURN
//CREATE GAME LOOP
do {
do {
cout<<"\n\nEnter Number:";
cin>> Guess; //GET USERS GUESS
if(Guess == SNum){ //IF USERS GUESS = SECRET NUMBER THEN THEY WIN
cout<<"\nYou win!" << endl;
}
else if(Guess == Sent){ //IF USERS ENTERS SENT, THEN GAME LOOP TERMINATES
cout<<"\nYou Lose!" << endl;
}
else { //ELSE REPEAT GAME LOOP
Guesses++;
cout<<"\nIncorrect Guess, Try again!" << endl;
}
}
while((Guess != SNum) && (Guess != Sent)); //WHILE GUESS IS NOT 0 OR THE SECRET NUMBER
//DISPLAY PLAYERS RESULTS AND END GAME MESSAGE
cout<<"\n\nTOTAL GUESSES:" << Guesses << endl;
cout<<"Would you like to play again? (Y/N)";
cin>>Again;
}
while((Again == "Y")||(Again="y")); //DECIDE WHETER TO REPEAT GAME LOOP OR TERMINATE GAME LOOP
if ((Again != "Y") || (Again !="y")) // CLOSE APPLICATION SAFELY
return(0);
}
Here is the code to my random.h file
Code:
#ifndef RANDOM_H
#define RANDOM_H
bool & randomEraseMultipleEdges(); // if set to true generators generate simple graphs
long & randomSetSeed(); // set the seed of the random generator
bool & randomSeed(); // wether program should start with a random seed
void randomInitSeed(); // called once, when program start
void randomStart(); // called when needed randoms number
void randomEnd(); // save a new seed
long randomGet(long range); // returns an integer >= 1 && <= range
#endif