用fopen打开大文件

时间:2018-02-12 19:16:36

标签: c fopen fseek

我需要获取文件的维度,所以我写了这段代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main () {

FILE *file;
char path[256];

long int fsize;

printf("Insert path of file: ");
fgets(path, 256, stdin);
path[strlen (path) - 1] = '\0';

file = fopen( path ,"rb");

if (file == NULL) {
perror("File 1 error: ");
exit(0);
}

fseek(file,0,SEEK_END);
fsize= ftell(file);
rewind(file);

printf("Dimension: %ld Bytes\n",fsize );

return 0;
}

代码有效,但是当我尝试打开一个大文件(13 GB)时,ftell返回0.我使用的是Windows 10 x64。 fopen可以打开或fseek拒绝对大文件进行操作的字节数是否有限制?

0 个答案:

没有答案
相关问题