thomaswang
V2EX  ›  问与答

C 语言问题

  •  
  •   thomaswang · Apr 9, 2018 · 2545 views
    This topic created in 3129 days ago, the information mentioned may be changed or developed.

    QQ20180409-224014.png

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

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

    5 replies  •  2018-04-10 08:26:00 +08:00
    htfy96
    htfy96
    Apr 9, 2018
    1
    fseek
    choury
    choury
    Apr 9, 2018
    2
    read(fd, buf+50, len)
    pkookp8
    pkookp8
    Apr 10, 2018 via Android
    3
    man 2 open
    man lseek
    man fopen
    man fseek
    Andiry
    Andiry
    Apr 10, 2018
    4
    pread 了解一下
    liuminghao233
    liuminghao233
    Apr 10, 2018 via iPhone
    5
    传指针的时候用 buf+50
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4986 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 07:23 · PVG 15:23 · LAX 23:23 · JFK 02:23
    ♥ Do have faith in what you're doing.