#include #include #include #include using namespace std; //using namespace System; int main(int argc, char *argv[]) { const int width = 80, // width of the console height = 25; // height of the console int randomWidth = 0, // used to store a random width randomHeight = 0; // used to store a random height char Display[width][height];// used to store a representation of the console COORD charPosition; // used to store information on the location of interest HANDLE hOut; // our handle to the console screen buffer DWORD cWritten; srand((unsigned)time(0)); // seed the pseudo random number generator with the current time hOut = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTitle( TEXT("Hurrah") ); randomWidth = (rand()%width)+1; randomHeight = (rand()%height)+1; charPosition.X = randomWidth; charPosition.Y = randomHeight; //initialze our console representatoin for (int i = 0; i < width; i++) for (int j = 0; j < height; j++) Display[i][j] = '\0'; if (Display[randomWidth][randomHeight] != 'O') { Display[randomWidth][randomHeight] = 'O'; WriteConsoleOutputCharacter( hOut, // screen buffer handle TEXT("O"), // pointer to source string lstrlen(TEXT("O")), // length of string charPosition, // first cell to write to &cWritten); // actual number written } cin.get(); return EXIT_SUCCESS; }