Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Guest Anonymous Poster

What is wrong with this?!

This topic is 6886 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yeah, in the future, make sure you describe the errors you're getting. But assuming that you have your project set as a Win32 Console Application, here's what's wrong.

First of all, you can't include graph.h. It's not part of the MSVC++ library, and your program doesn't need it anyway (I may be wrong here, but I believe it's the Microsoft C/Microsoft Visual C graphic header, but only for DOS).

Second, although it will compile, the way you are tring to get the clock is going to cause a crash. Delete the line unsigned int far *clock = (unsigned int far *)0x0000046CL; // pointer to clock entirely, include the header time.h, and change srand(*clock) to srand(time(NULL)). That should do it.

- Dave

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
The below is some source code that makes a simple guessing game... I finally know how to get my applications to run in dos, but whenever I try to compile and build the following code, it comes up with 1 error. Here's what it allll does:
You're supposed to guess a number between 1 - 100, and if the user's guess is too big, it says so and vice versa. Once the user has guessed the correct number, it displays that he got it, and tells him/her how many tries it took to get it...
Please look at the below code, and tell me why it won't compile in Visual C++!!

// GUESS.C - An example of input driven event loops

// I N C L U D E S ////////////////////////////////////////////////////////////

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <graph.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 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


// choose a random number from 1-100

number = 1 + rand() % 100;

// SECTION 2 //////////////////////////////////////////////////////////////////

// main event loop


// SECTION 3 //////////////////////////////////////////////////////////////////

// query user for input (the event)

printf("\nWhat's your guess?");

// SECTION 4 //////////////////////////////////////////////////////////////////

// increment number of tries


// process the event

if (guess > number)
printf("\nToo big!\n");
if (guess < number)
printf("\nToo small!\n");
// the user must have guessed the number

printf("\nYou guessed the number in %d tries!!!\n",num_tries);

// set the exit flag


} // end else

} // end while

} // end main

[This message has been edited by Myopic Rhino (edited December 10, 1999).]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!