C 替換檔案中指定的內容

2021-06-07 10:22:51 字數 459 閱讀 5623

/*實現替換檔案中指定的內容

----created by cryking----

--------2012.02.12--------*/

#include#include#include#includeusing namespace std;

char *strstr_rep(char *source,char *old,char *ne)//字元替換

strstr_rep(buffer,"2222","8888");//將"2000"替換為8888"

outfile.close();

ofstream infile("test.txt");

while(k!=i)//將buffer全部寫入到檔案

outfile.close();

return 0;

}

很久沒敲**了,唉。。。手生了!!!

替換檔案中指定的內容並儲存之sed命令

root localhost sed nefri command 輸入文字 常用選項 n 使用安靜 silent 模式。在一般 sed 的用法中,所有來自 stdin的資料一般都會被列出到螢幕上。但如果加上 n 引數後,則只有經過sed 特殊處理的那一行 或者動作 才會被列出來。e 直接在指令列模式...

python替換檔案中的指定內容

編寫的python程式,檔名是file replace.py,具體 如下 usr bin env python coding utf 8 import sys,os if len sys.argv 4 or len sys.argv 5 sys.exit there needs four or fi...

php替換檔案指定行的內容

1 第一種 利用file 函式 讀取檔案,每一行都是乙個陣列元素 2 arr file file 3 arr line hello 4file put contents file,implode arr 5 6 第二種7 8 fp new splfileobject test.php r 9 轉到第...