c语言,跳过字节读取、盗墓者是个丑奴儿

//盗墓者是个丑奴儿,原

//博主个人网站 :https://daomu.kaige123.com

//打完一波小广告,进入正题

 

#include
#include
#include
#include
#include
#include
#include
#include

 

//open打开文件,lseek向后偏移字节,偏移后read在读取。

//SEEK_SET从头向后偏移

//O_RDWR以已可读可写方式打开文件

 

int main(void){

        int i=open("stu.java",O_RDWR);

        char buf[100]={0};

        int ffd=lseek(i,3,SEEK_SET);

        read(i,buf,100);

        printf("%s \n",buf);

        close(i);

        return 0;

}

 

运行结果:

偏移3字节后,读取:

c语言,跳过字节读取、盗墓者是个丑奴儿_第1张图片

原文件内容:

c语言,跳过字节读取、盗墓者是个丑奴儿_第2张图片

你可能感兴趣的:(C习题)