I need to get the dimension of a file, so I wrote this code:
#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;
}
The code works, however when I try to open a big file (13 GB) ftell returns 0. I'm using Windows 10 x64. Is there a limit on the number of bytes that fopen can open or fseek refuses to operate on big files?