Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
如何精确修改文件某字节
Experiences and Insight
686
views ·
5
replies ·
To
floor
Go
iamcook84
deepin
2015-11-28 06:11
Author
比如把文件的某字节改成'a' 或者清空。不用 cut 命令,直接编程,要用 C 语言的什么函数?
Reply
Like 0
Favorite
View the author
All Replies
much1988
deepin
2015-11-28 07:56
#1
open , 然后全读出来,然后偏移到那个字节处,改掉。重写一个file 就完了。
Reply
Like 0
View the author
much1988
deepin
2015-11-28 07:58
#2
或者,直接打开文件 seek 到那个位置 先删再write。不过我没试过。
Reply
Like 0
View the author
emofode
deepin
2015-11-28 08:09
#3
hexedit
Reply
Like 0
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
Like 0
View the author
iamcook84
deepin
2015-11-28 19:01
#5
如何删除呢?
Reply
Like 0
View the author
Please
sign
in first
New Thread
Popular Events
More