如何精确修改文件某字节
Tofloor
poster avatar
iamcook84
deepin
2015-11-28 06:11
Author
比如把文件的某字节改成'a' 或者清空。不用 cut 命令,直接编程,要用 C 语言的什么函数?
Reply Favorite View the author
All Replies
much1988
deepin
2015-11-28 07:56
#1
open , 然后全读出来,然后偏移到那个字节处,改掉。重写一个file 就完了。
Reply View the author
much1988
deepin
2015-11-28 07:58
#2
或者,直接打开文件 seek 到那个位置 先删再write。不过我没试过。
Reply View the author
emofode
deepin
2015-11-28 08:09
#3
hexedit   
Reply View the author
much1988
deepin
2015-11-28 08:09
#4
FILE *fp = fopen("tmp.txt","r+");
        fseek(fp,2,SEEK_SET);
        fwrite("2",1,1,fp);
        fclose(fp);

        return 0;
Reply View the author
iamcook84
deepin
2015-11-28 19:01
#5
如何删除呢?
Reply View the author
New Thread

Popular Events

More
国际排名
WHLUG