Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
493 views
in Technique[技术] by (71.8m points)

c - 如何寻找到文件结尾以确定文件大小?(how to seek to the end of file to determine the file size?)

I'm trying to get file size in c programming using seek.

(我正在尝试使用seek在c编程中获取文件大小。)

I can't use fseek , stat.size nor ftell , there's a custom operating system UNIX in which I need to run.

(我不能使用fseek ,stat.size或ftell ,我需要在其中运行自定义操作系统UNIX。)

How can I find out filesize just by using seek?

(如何仅通过使用seek找出文件大小?)

Is it possible?

(可能吗?)

  FILE *fd = open(argv[1], "r");

  if(fd == NULL)
  {
    printf("Not able to open the file : %s
", argv[1]);
    return;
  }

  // Set the pointer to the end
  seek(fd, 0, SEEK_END);
  ask by Abhilash Muthuraj translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

seek ?

(seek ?)

You mean lseek probably.

(您的意思可能是lseek 。)

Have a look at the manual page .

(看一下手册页 。)

What does lseek return?

(lseek返回什么?)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...