Thread: error help

  1. #1
    Programmer Frantic-'s Avatar
    Join Date
    Dec 2004
    Posts
    114

    error help

    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

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Great, now how about explaining a few things:

    1) What is this program supposed to do?

    1a) What does it do right?
    1b) What does it do wrong?
    1c) What doesn't it do that it should?

    It's nice that you actually used code tags, but it helps if you actually say something other than "here's some code". Great, there's some code. Big deal. Means nothing at all to me. How about asking a question with your code dump?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    int SNum = long randomGet(long 100); //SECRET NUMBER

    ...You're assigning a regular int to a long.... And also you don't need to give the return type of the function when you call it. Problemo solvedos.

Popular pages Recent additions subscribe to a feed