// console.h by Gary Frankenbery // Grants Pass High School // Grants Pass, OR /*To use console.h, copy it to the c:\Prrogram Files\Microsoft Visual Studio\VC98\include directory Place #include "console.h" in your program clrscr() -- clears the screen and places the cursor in the upper left corner. Note that I implemented this in two different ways, and that the long method has been commented out. void gotoxy(int, int) -- positions the cursor on the screen, with (1,1) being the upper left corner. void randomize() -- seeds the random number table according to the clock tick timer. int random(int) -- returns a random integer in the range 0 to int-1. int getch() -- waits for a keypress, returns the keypress, then moves on. Does NOT echo keypress to the screen (does NOT use iostreams). Does NOT wait for the user to press the Enter key. int getche() -- same as getch() except it echoes the character typed to the screen. void delay(long) -- long is the number of milliseconds to delay. Code: */ // console.h // contains functions to translate Borland C++ // console operations to Microsoft Visual C++ // console.h by Gary Frankenbery // Grants Pass High School // Grants Pass, OR #include // for console operations #include // for rand(), srand() #include // for time() #include // for _getch() and _getche() // gotoxy() Positions cursor relative to the upper // left corner of the screen. In Borland's // conio.h, the upper left corners is (1,1), // while in Microsoft's // SetConsoleCursorPosition()the coordinates // of the upper left corner are (0,0). Note // the adjustment to x and y below to use // Borland's scheme. void gotoxy(int,int); // clrscr() Clears the screen, and sets the cursor // to position (1,1), the upper left // corner. void clrscr(); void delay(long); // delay 'msecs' milliseconds // randomize() Seeds the random number generator. // void randomize(); // returns a random number in range 0 to num-1 int random(int); // Waits for and returns a keypress (no echo) int getch(); // Waits for and returns a keypress with echo int getche();