here you a go, I'm new to C so please show me a better way of this is wrong, thanks.
int filesize(FILE *handle)
{
fseek(handle,0,SEEK_END);
fsize=ftell(handle);
return fsize;
}
here you a go, I'm new to C so please show me a better way of this is wrong, thanks.
int filesize(FILE *handle)
{
fseek(handle,0,SEEK_END);
fsize=ftell(handle);
return fsize;
}
@xoid:
an int possibly won't be big enough to hold the file size. Besides, ftell() returns a long int.
Also, fseeking to the end of a file isn't guaranteed to tell you the correct answer to the question. The file open mode can affect the answer too.
http://www.eskimo.com/~scs/C-faq/q19.12.html
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
maybe I'm wrong, but if you want to find an exact filesize you need Unix, LOL, I'm using windows, Visual C++ 6 compiler currently learning ANSI C, anything I could use that will guarantee the correct filesize?
thanks in advance
Use a binary open mode in your fopen() call. Then you can fseek()/ftell()
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
cool, is that the most efficient method under windows?
Yep.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
You may also want to look up _stat() in MSDN or GetFileSize()Originally posted by Xoid
cool, is that the most efficient method under windows?
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
aah! many thanks!