Mail Archives: djgpp/1999/08/14/21:56:54
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 -