V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
thomaswang
V2EX  ›  问与答

C 语言问题

  •  
  •   thomaswang · 2018-04-09 22:43:35 +08:00 · 1615 次点击
    这是一个创建于 2202 天前的主题,其中的信息可能已经有所发展或是发生改变。

    QQ20180409-224014.png

    int fd; // 文件描述符
    char buf[100];
    想从 fd 读取 50 字节放到 buf 里,但是起始位置不是 0, 该咋写
    
    

    不要申请额外的内存,然后拷贝到 buf 里

    5 条回复    2018-04-10 08:26:00 +08:00
    htfy96
        1
    htfy96  
       2018-04-09 22:53:51 +08:00
    fseek
    choury
        2
    choury  
       2018-04-09 22:54:10 +08:00
    read(fd, buf+50, len)
    pkookp8
        3
    pkookp8  
       2018-04-10 01:22:24 +08:00 via Android
    man 2 open
    man lseek
    man fopen
    man fseek
    Andiry
        4
    Andiry  
       2018-04-10 02:00:22 +08:00
    pread 了解一下
    liuminghao233
        5
    liuminghao233  
       2018-04-10 08:26:00 +08:00 via iPhone
    传指针的时候用 buf+50
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2538 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 01:12 · PVG 09:12 · LAX 18:12 · JFK 21:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.