I'm trying to get file size in c programming using seek. I can't use fseek
, stat.size nor ftell
, there's a custom operating system UNIX in which I need to run.
How can I find out filesize just by using seek? Is it possible?
FILE *fd = open(argv[1], "r");
if(fd == NULL)
{
printf("Not able to open the file : %s\n", argv[1]);
return;
}
// Set the pointer to the end
seek(fd, 0, SEEK_END);
seek
? You mean lseek
probably. Have a look at the manual page. What does lseek
return?