http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can anyone hlelp??~~



 
----- Original Message -----
Sent: Monday, October 16, 2000 7:18 PM
Subject: RE: Can anyone hlelp??~~

My first guess would be that you don't really have access to the clock this way, butI would need more information.  What OS are you running?  What happens if you just initialize srand  with 1 (or 0)?  How far do you get if you comment out the "unsigned int *clock = (unsigned int *)0x000046CL; // pointer to clock" line of code?
 
If this doesn't help, ask for more help/
 

Kevin Wolfskill
JADE Solutions
Office US  (303) 583-4123
Fax US      (303) 449-1548
Kevin.Wolfskill@jadesolutions.com
______________________________________
WARNING - THIS E-MAIL TRANSMISSION IS CONFIDENTIAL.
This e-mail transmission (including any accompanying attachments)
contains confidential information which is intended for the named addressee only. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution or reproduction of this e-mail is prohibited. If you have received this e-mail in error please contact

me immediately. Thank you.
_______________________________________



-----Original Message-----
From: warpedminds [mailto:warpedminds@btinternet.com]
Sent: Monday, October 16, 2000 11:51 AM
To: gameprogrammer@gameprogrammer.com
Subject: Can anyone hlelp??~~

I'm having trouble with this bit of code I've got for college.  It compiles fine but as soon as it runs it comes back with an illegal operation.  I just con't figure it out!  Can anyone help??
 
 
 

// I N C L U D E S ////////////////////////////////////////////////////////////
 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
 
 
// M A I N ////////////////////////////////////////////////////////////////////
 
void main(void)
{
 
int done=0,        // exit flag
    number,        // the random nunber
    num_tries=0,   // number of tries
    guess;         // the players guess
 
unsigned int *clock = (unsigned int *)0x000046CL; // pointer to clock
 
// SECTION 1 //////////////////////////////////////////////////////////////////
 
// print out introductory instructions
 
printf("\nI'm thinking of a number from 1-100.");
printf("\nTry and guess it!\n");
 
// seed the random number generator with the time
 
srand(*clock);
 
// choose a random number from 1-100
 
number = 1 + rand() % 100;
 
// SECTION 2 //////////////////////////////////////////////////////////////////
 
// main event loop
 
while(!done)
     {
 
// SECTION 3 //////////////////////////////////////////////////////////////////
 
     // query user for input (the event)
 
     printf("\nWhat's your guess?");
     scanf("%d",&guess);
 
// SECTION 4 //////////////////////////////////////////////////////////////////
 
     // increment number of tries
 
     num_tries++;
 
     // process the event
 
     if (guess > number)
        printf("\nToo big!\n");
     else
     if (guess < number)
        printf("\nToo small!\n");
     else
        {
        // the user must have guessed the number
 
        printf("\nYou guessed the number in %d tries!!!\n",num_tries);
 
        // set the exit flag
 
        done=1;
 
        } // end else
 
     } // end while
 
} // end main
 
 
 
ANY help would be appreciated.
 
Also, someone told me to include the graph.h, but Visual Studio 6.0 doesn't seem to have that. What difference would it make me anyway??
 
> --------------------------------------------------------------------------------------------------------------------------------------- <
 
Hi,
 
To answer your questions, I am using win 98 (with VS C++ 6.0 compiler/editor).  I was given this code by my college to edit. I had to make the random more random by using the system clock.  The original code had graph.h at the pre-processor stage but my compiler could'nt find it in my include DIR, if that will make any difference.  Also, if I comment out the line unsigned int *clock = (unsigned int *)0x000046CL; // pointer to clock and initialize rand with 1 it works fine but this isn't really any good because I need to use the timer so that I can pass the assessment at college.
I have seet rand() being initialized by the timer in other examples of such a program and it worked fine in them but it just won't work in mine.
 
Also, in the other couple of examples I have seen this implemented with had used graph.h, I don't know if this would effect it. Do you know what graph.h is used for??
 
Thanks.