www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/10/06:39:02

Date: Tue, 10 Feb 1998 13:34:41 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Richard Chappell <Pixnaps AT netaccess DOT co DOT nz>
cc: djgpp AT delorie DOT com
Subject: Re: Randon Function
In-Reply-To: <34dfe7b8.6111175@news.netaccess.co.nz>
Message-ID: <Pine.SUN.3.91.980210133234.12622O-100000@is>
MIME-Version: 1.0

On Tue, 10 Feb 1998, Richard Chappell wrote:

> >char * read_one_line( char *buf, int len, int seek_line, FILE *fp )
> >{
> [snip]
> >}
> 
> So if I wanted to use this function in a program, would I have:
> 
> char *mypc;
> mypc=read_one_line(&mypc, myLenWanted,myLineWanted,"data.txt");

No.  FILE *fp is NOT a string!  It is a pointer returned by `fopen'.  So 
at least you should have said this:

mypc=read_one_line(&mypc, myLenWanted,myLineWanted,
		   fopen("data.txt", "r"));

I would also check the value returned from `fopen', since it could be a 
NUL pointer if the file didn't exist, for example.

- Raw text -


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