I have a customer's file that is very nearly 4gb. I have a C++ program I'm using on it and the first thing it has to do is find the total bytes in the file. I use the same program with lots of other files also. It works fine even with this huge file, but it takes at least a minute or so (much longer if the computer's doing other things, which is often the case) just to do the fseek to the end of the file. Is there any faster way to find the size of the file? It gets pretty tedious when I'm making changes to the program and having to test it over and over and waiting while it gives the impression of just spinning its wheels. And since this program is used with many other files and by users other than just myself, any solution would need to be portable and nonspecific to this one file.
If you are on Windows, and what is required is the total bytes in the file, you could use GetFileSizeEx() http://msdn.microsoft.com/en-us/library/windows/desktop/aa364957(v=vs.85).aspx
If the file is a text file, and you need get the size of the file in terms of number of chars (not number of bytes on disk), there is no other way other than reading every byte from the beginning of the file to the end, performing escape sequence translations for new-lines. This will take time on large files.