![](wink.gif)
newbie in C/C++ looks out for help
howdy pps!
recently i bought "black art of 3d g ame programming". i bought this book to learn about principles of root 3d algorithms and structures of c/c++. i bought also 2 books for c/c++ for the bases.
so in "black art..." the snippets are codet in MS and BORLAND compilers from about 1995. i tried the examples, got problems with "graph.h" and so on... now i know, graph.h is in older MS versions and the snippets are separately for BORLAND on cd.
i (clever as i am) checked the examples, anbd there was no "graph.h" no mo'' biczuz...
)
but now, i tried to compile this code in my hot hot hot "BORLAND 5 ENToRPRIzE" and what now? some shyzee syntax error with shytty syntax... bah! shytty far call!!!
ps: after i left the "far" far away, there was an exception fault on adress blah:blah...
here''s the code, in line 21 the "unsigned int far *clock = (unsigned int far *)0x0000046CL; // pointer to clock" is the erroneous piece...
TO ALL WHO READ THIS: WHAT CAN I DO TO RECREATE THE SNIPPETS FROM THIS BOOK? ANYBODY WITH ABANDON COMPILERS TO HELP ME? I TRIED ABOUT YEARS TO GET THE F* START IN C/C++ CODING BUT ARGHSSS!!! PLEASE HELP A LONELY SOUL!
// GUESS.C - An example of input driven event loops
// I N C L U D E S ////////////////////////////////////////////////////////////
#include
#include
#include
// 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 far *clock = (unsigned int far *)0x0000046CL; // 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
and don''t tell me i shud use openGL... BASES!!! BASES!!!!!!!!!! :D
peez
cdeath
![](wink.gif)
Just a piece of advice: you might get more replies if your question is more concise. Having to wade through kiddie-script with intentional mispelling and excessive punctuation to find some factual information is annoying.
I gather from your post that you are trying to compile a program for DOS. I am far from an expert DOS programmer, but I think your program is assuming that the value of the clock can be read from a certain fixed address. DOS is dead for most application development, so I would advise that you learn Linux or Windows programming.
If you want to fix your program, include time.h and remove the clock pointer. Then replace the srand call with this:
I gather from your post that you are trying to compile a program for DOS. I am far from an expert DOS programmer, but I think your program is assuming that the value of the clock can be read from a certain fixed address. DOS is dead for most application development, so I would advise that you learn Linux or Windows programming.
If you want to fix your program, include time.h and remove the clock pointer. Then replace the srand call with this:
srand(time(0));
April 16, 2001 03:17 PM
Listen man, you cant expect to run a program that expects ring-0 real time privileges under an os that is expecting your app to operate nicely on ring-3. If you are trying to make a dos app, make sure you compiler knows that too so it will compile a 16 bit dos executable. When you run a dos app under windows, windows checks the exe and if it is a dos exe it emulates dos through a VXD that allows you to call standard dos interrupts etc. Otherwise, run your dos app under dos to avoid exception faults, or use the proper API functions to access the hardware you want to access and build a win32 executable.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement