Quote:
> I'm trying to determine the size of an error log file [...]
> Is there any simple way to do that?
> [...]
> ptf = fopen (Error_file, "w+");
1. Using FILE*
long save = ftell(ptf);
fseek(ptf, 0, SEEK_END);
long file_size = ftell(ptf);
fseek(ptf, save, SEEK_SET);
2. Using GetFileSize (Windows API, required for 64-bit files)
HANDLE hFile = CreateFile(
Error_file,
GENERIC_READ|GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
0);
if (hFile != INVALID_HANDLE_VALUE)
DWORD file_size = GetFileSize(hFile, 0);