My application creates a large file and I am trying to use _lseeki64() to position the file pointer. I have found that after a write I need to call fflush() to make it work correctly. If I call it after a read using SEEK_CUR it always positions the file relative to the end.
I have found some references on the internet to _fseeki64() and _ftelli64() but I cannot find them in any include file or library.
Any assistance would be greatly appreciated
CaKiwi
I have found some references on the internet to _fseeki64() and _ftelli64() but I cannot find them in any include file or library.
Code:
#include "stdafx.h"
#include <io.h>
int _tmain(int argc, _TCHAR* argv[])
{
FILE *fp;
char buf[256];
__int64 i64;
fp = fopen("test.txt","w");
fwrite("123456789A123456789B123456789C123456789D", 40, 1, fp);
i64 = _lseeki64(_fileno(fp), (__int64)-10, SEEK_CUR);
printf("Before fflush = %d\n", i64);
fflush(fp);
i64 = _lseeki64(_fileno(fp), (__int64)-10, SEEK_CUR);
printf("After fflush = %d\n", i64);
// i64 = _ftelli64(fp);
fclose(fp);
fp = fopen("test.txt","r");
fread(buf, 20, 1, fp);
i64 = _lseeki64(_fileno(fp), (__int64)-10, SEEK_CUR);
printf("From current postion after read = %d\n", i64);
i64 = _lseeki64(_fileno(fp), (__int64)10, SEEK_SET);
printf("From beginning of file after read = %d\n", i64);
fclose(fp);
return 0;
}
Any assistance would be greatly appreciated
CaKiwi