www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/14/21:56:54

From: "Bas Hamstra" <bas DOT hamstraNOSPAM AT wxs DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: length of file (baffling me)
Date: Sun, 15 Aug 1999 02:31:28 +0200
Organization: Planet Internet
Lines: 33
Message-ID: <7p51mk$qg2$1@reader1.wxs.nl>
References: <7p3u7u$ncb$1 AT nnrp1 DOT deja DOT com> <37B5BAFA DOT 504E01BB AT unb DOT ca>
NNTP-Posting-Host: gn0122-2.dial.wxs.nl
Mime-Version: 1.0
X-Trace: reader1.wxs.nl 934677012 27138 195.121.152.122 (15 Aug 1999 00:30:12 GMT)
X-Complaints-To: abuse AT wxs DOT nl
NNTP-Posting-Date: 15 Aug 1999 00:30:12 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3155.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Endlisnis heeft geschreven in bericht <37B5BAFA DOT 504E01BB AT unb DOT ca>...
>jsc AT lds DOT co DOT uk wrote:
>
>> Hello all, this must be an easy question, but I can't seem to get it to
work.
>> All I'm trying to do is work out the length of a file. I use
>>
>> FILE *fp;
>> fp = fopen(filename, "rb");
>> printf( "File length: %i", filelength((int)fp) );
>>
>> I get -1 returned, indicating an error, but I can't see why.
>> If anyone could help, I'd really appreciate it.
>
>If you would have read the documentation on the filelength function, you
would
>have discovered that it takes an argument of a filedescriptor, and you
can't just
>cast a FILE* to an int and hope it works.  The docs clearly say to use the
fileno
>macro.
>
>printf("File length: %i", filelength(fileno(fp)));

Man, can''t you try to be a bit more friendly? Be nice! Just answer the
question and don't go "if you had done this, you would have known that".






- Raw text -


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