delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/07/06:16:16

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Randon Function
Date: 7 Feb 1998 06:44:49 GMT
Organization: The National Capital FreeNet
Lines: 18
Message-ID: <6bgvt1$ruu@freenet-news.carleton.ca>
References: <6bgtsb$h8o AT alpha DOT delta DOT edu>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet5.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

"Matt Kris" (jdkris AT NOPOOPalpha DOT delta DOT edu) writes:
> I need to make a function that will open a text file that contains a list of
> 100 words and take a randon word and store it in  an array.  I made a
> function that will open the file and read the first word but I don't know
> how to read the other lines.  Is there a way to move through files like
> that?  Please help.

Easy. Obtain a random number r from 0 to 99. Open the file. Then for (i=0;
i<r; i++) { read a line and discard it using an appropriate file input
command }, then read a line and use that as the name.


--
    .*.  Friendship, companionship, love, and having fun are the reasons for
 -()  <  life. All else; sex, money, fame, etc.; are just to get/express these.
    `*'  Send any and all mail with attachments to the hotmail address please.
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca pgd73 AT hotmail DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019