#define _FILE_OFFSET_BITS 64
#define fseek64 fseeko64
#define ftell64 ftello64
#include <stdio.h>
int main()
{
FILE *fp;
char str[] = "e81ae5272 Modify the frame rate and update the library e81ae5272 Modify the frame rate and update the library";
fp = fopen("data.txt", "wb+");
unsigned long long int i = 0;
unsigned long long int size = 10000 * 1000 * 2.5;
for (i = 0; i < size; i++)
{
if (i % 100 == 0)
printf("tell:%lu\n", ftell64(fp));
fwrite(str, sizeof(str), 1, fp);
}
printf("final size:%lu\n", ftell64(fp));
fclose(fp);
return (0);
}
宏定义可以写在代码中,可以编译时增加;
另外不能再使用fseek
和ftell
使用,当文件大小超过FFFFFFFF
时会溢出。
需要使用fseeko64
和ftello64
。