Quote Originally Posted by Elysia View Post
Not to mention FILE is not an array, so trying to walk it using ++ would be undefined behavior.
Actually, I wouldn't want to guarantee that FILE is NOT an array - in many systems it would be. The problem with using ++ on a file-pointer, however, is that the struct FILE is not a known type in the application side, it's only known in the C-library side of the code (it's called an opaque pointer - it's a pointer to a struct, but you never "look inside it").

Being an opaque pointer means that there's no way to use ++ on it, since the compiler is not able to figure out how much forward it should jump.

And of course, even if we could "walk" the list of FILE structs, the code would definitely not tell you how big the file is - it would return some random value that is completely and utterly unrelated to the size of the file itself.

--
Mats