用 fopen();開檔
然後 fgets();讀資料
接著將讀到的資料改成你要的
覺得可以用 sprintf 或者是 fprintf....
將改過的資料先存在別的檔案或者是戰存的鎮列
到了最後在...恩恩 找到了... rewind();
回到test.txt的開頭 然後寫入
我想到的方法是這樣子啦
#include <stdio.h>
#define BUF_SIZE 1024
int main(void){
FILE *op,*temp;
char buf[BUF_SIZE];
...
/*---- open the file stream ----- */
...
/*---- read the data from 'test.txt. and change the data ----*/
/*---- write the data into temp_file -----------------------*/
...
/*---- copy the file of temp_file to 'test.txt.--------------*/
rewind(op);
...
return 0;
}
--
或許人生是一段整合內在的自己
並尋求人間一點真情的過程吧
--
[1;31mO [1;32mr [1;33mi [1;34mg [1;35mi [1;36mn [1;31m: [1;36m<不良牛牧場> [1;33mzoo.ee.ntu.edu.tw [1;32m(140.112.18.36) [m
[1;32mWelcome to SimFarm BBS [1;36m-- [m [1;31mFrom : [ [m140.112.249.54 [1;31m] [m