我正在尝试使用 seek 在 c 编程中获取文件大小。我不能使用fseek
stat.size ftell
,也不能使用我需要在其中运行的自定义操作系统 UNIX。
如何仅使用 seek 找出文件大小?可能吗?
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);