set eof indicator in files
I write a program that replaces a string in file. i open file as r+ mode in C. eve开发者_运维问答rything is ok now but when the program replaces the string, filesize will be reduced, for example i have a file whose content is
abcDEFgh
i want to replace DEF with AA, it becomes
abcAAFgh
but there will be null space after 'h' charecter.
So here is the problem, i want to set EOF flag after the 'h' charecter like null charecter(\0) in strings.
I found an article about that in AppleScript, is it possible to do that in C?
http://docs.info.apple.com/article.html?path=AppleScript/2.1/en/as202.html
You should truncate the file using ftruncate. Saw this issue in OSx before
精彩评论