c

来自「C程序设计经典900例.zip」· 代码 · 共 30 行

TXT
30
字号
#include <stdio.h>
#include <io.h>
#include <share.h>
#include <fcntl.h>

void main(void)
 {
   int handle;
   int offset = 0;
   int bytes_read;
   char buffer[128];

   if ((handle = sopen("\\AUTOEXEC.BAT", O_BINARY | O_RDONLY, SH_DENYNO)) == -1)
     printf("Error opening AUTOEXEC.BAT\n");
   else
    {
      while (bytes_read = read(handle, buffer, 1)) 
       {   
         if (bytes_read == -1)
           printf("Error reading offset %d\n", offset);
         else
           write(1, buffer, bytes_read);
         offset++;
         lseek(handle, offset, SEEK_SET);
       }
      close(handle);
    }
 }

⌨️ 快捷键说明

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