Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
ReputationZh
V2EX  ›  Linux

Linux 下用 C 语言对二进制文件操作,我想删除末尾 16 位数据(不是清零是删除),应该怎么办?

  •  
  •   ReputationZh · Aug 6, 2020 · 3665 views
    This topic created in 2286 days ago, the information mentioned may be changed or developed.
    查阅了一上午资料,没找到解决办法 TAT 。
    8 replies  •  2020-08-06 14:58:19 +08:00
    fmumu
    fmumu
    Aug 6, 2020 via Android
    1
    truncate ?
    zyffy
    zyffy
    Aug 6, 2020
    2
    ftruncate
    tomychen
    tomychen
    Aug 6, 2020
    3
    new_size = getfilesize()-16;// 自己实现
    fread(data,size, oldfile);
    fwrite(data, new_size,oldfile);//or newfile
    julyclyde
    julyclyde
    Aug 6, 2020
    4
    删除?右移?
    ReputationZh
    ReputationZh
    OP
    Aug 6, 2020
    5
    @zyffy 这个函数的第一个参数是 int ? 有没有具体用法。
    trn4
    trn4
    Aug 6, 2020 via iPhone
    6
    @ReputationZh man truncate
    Cooky
    Cooky
    Aug 6, 2020 via Android
    8
    truncate
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4430 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 09:14 · PVG 17:14 · LAX 01:14 · JFK 04:14
    ♥ Do have faith in what you're doing.