How to use MSVC++ random in gcc 3.2.2?

John Love-Jensen eljay@adobe.com
Fri May 2 12:22:00 GMT 2003


Hi Jim,

Here's my Unix rewrite, presuming ANSI escape sequences.  Not tested, just
off the cuff.

#include <iostream>
  using std::cout;
  using std::endl;
  using std::flush;
#include <cstdlib> // srandomdev, random

// ANSI escape sequence cursor positioning.
// row is 1 ... 24
// col is 1 ... 80
void gotoxy(int col, int row) {
  cout << "\x1B[" << row << ";" << col << "H" << flush;
  }

int main() {
  srandomdev();
  cout << "Doodler!  Press I/J/K/M to move, Q to quite" << endl;
  char KeyPressed;
  int x = 40;
  int y = 10;
  char Character = '*';
  do {
    // Plot a "point".
    gotoxy(x, y);
    cout << Character << flush;
    goto(x, y);

<snip>

--Eljay



More information about the Gcc-help mailing list