tell.c

来自「C语言900例。学c语言的可以从这900例中受益匪浅」· C语言 代码 · 共 25 行

C
25
字号
#include <stdio.h>
#include <io.h>
#include <fcntl.h>

void main(void)
 {
   int handle;
   char buffer[512];
   int bytes_read;

   if ((handle = open("\\CONFIG.SYS", O_RDONLY)) == -1)
     printf("Error opening \\CONFIG.SYS\n");
   else
     {
       printf("Current file position %ld\n", tell(handle));

       while (bytes_read = read(handle, buffer, sizeof(buffer)))
         write(1, buffer, bytes_read);

       printf("Current file position %ld\n", tell(handle));
       close(handle);      
     }
 }
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?