This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to use MSVC++ random in gcc 3.2.2?


"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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]