This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to use MSVC++ random in gcc 3.2.2?
- From: Oscar Fuentes <ofv at wanadoo dot es>
- To: gcc-help at gcc dot gnu dot org
- Cc: christiansen_j at hotmail dot com
- Date: Thu, 01 May 2003 23:57:10 +0200
- Subject: Re: How to use MSVC++ random in gcc 3.2.2?
- Cancel-lock: sha1:m6qxe1awBsfKgUzPQ0IoL3ErOUk=
- References: <Law11-F1226YoWmIzS000018cbb@hotmail.com>
"Jim Christiansen" <christiansen_j@hotmail.com> writes:
> Hello,
>
> I think that this may be the last question for a couple of weeks...
>
> What should I do to utilize teaching material using references to random?
>
> This is from Lawerneceville Press for grade 11 introductory
> programming using MSC++ v6. I'm trying to move all of our computers
> to Linux, and I'm finding small probelms such as iostream vs
> iostream.h ... Maybe random will be the last of my problems for this
> simple progamming.
I'm afraid is not. See below.
> <snip>
>
> #include <iostream.h>
> #include <conio.h>
> #include <lvp\random.h>
>
> int main()
> {
> randomize();
> cout << "Doodler! Press I/J/K/M to move, Q to quit" << endl;
> char KeyPressed; // Key pressed by user
> int x=40; // Establish initial position of cursor
> int y=10;
> char Character = '*'; // Initial char that is displayed
> do {
> // Plot a "point"
> gotoxy(x, y);
> cout << Character;
> gotoxy(x, y); // Move blinking cursor under current spot
For this piece of source code, 'random' is the least of your
problems. AFAIK, there is not conio.h available for *nix. So no
'gotoxy' and other DOS console functions. You could use the "curses"
library, which is far more complete than conio.h, but more complex
as well.
OTOH, take a look at the ISO C functions 'rand', 'random', and
'srand'.
--
Oscar