Mail Archives: djgpp/1998/02/10/06:39:02
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 -