首页 > 解决方案 > 在 C 中使用 pread()

问题描述

我试图使用 pread() 读取文件,但我得到“函数 'pread' 的隐式声明在 C99 中无效”。有没有办法处理这个?

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char **argv) 
{
        char dst[20];
        int file = open("file.txt", O_RDONLY);
        int read_res = pread(file, dst, 10, 3);
        close(file);
        return 0;
}

标签: cunistd.h

解决方案


推荐阅读