作者dozer (rezod)
看板LinuxDev
標題[問題] I/O in C
時間Tue Nov 28 15:44:02 2006
想要在一個用fopen打開的檔案中
插入一行字
比如說 原本的檔案長這樣
first line
second line
@
lastline
想要在@前面加入一行 third line, i.e.
first line
second line
third line
@
lastline
有沒有除了全部讀到buffer裏面 再重新寫入之外的方法哩
因為那樣就不能處理很大的檔案了...
--
It is a hard matter, my fellow citizens, to argue with the belly,
since it has no ears.
-- Marcus Porcius Cato
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.109.176.56
推 kkdlin:sed?? 用system去call 11/28 16:12
推 dozer:有沒有辦法全部用C 11/28 16:14
→ dozer:因為想儘量跨平台... 11/28 16:14
→ bullfrogtwn:buffer 應該是 libc 內部去實做的,這邊應該只要對 11/29 00:17
→ bullfrogtwn:讀入和寫出的 file pointer 做處理即可 ... ? 11/29 00:18
推 dozer:噢我說的buffer是自己開的char[] :P 11/29 21:40