C 從檔案中查詢特定的字串,並提取該字串

2021-06-18 11:44:35 字數 537 閱讀 2582

記錄乙個小技巧,使用c++從檔案中查詢特定標記的字串,並提取該字串。

用到了cstring的方法,十分的簡單,用於資料分析很方便。

這是我擷取的壓縮編碼試驗程式中的**,通過這段**可以提取x264輸出的ssim值

file *fp_statfile=fopen("x264_output.txt","rb");

cstring filecontent("");

//檔案內容讀入記憶體

while(!feof(fp_statfile))

//查詢x264的ssim數值

//x264特徵字串

cstring featurestr("ssim mean y:");

//查詢,返回字串位置

int paraloc=filecontent.find(featurestr);

cstring parastr;

//找到了的話

if(paraloc!=-1)

fclose(fp_statfile);

C 從檔案中查詢特定的字串,並提取該字串

記錄乙個小技巧,使用c 從檔案中查詢特定標記的字串,並提取該字串。用到了cstring的方法,十分的簡單,用於資料分析很方便。這是我擷取的壓縮編碼試驗程式中的 通過這段 可以提取x264輸出的ssim值 file fp statfile fopen x264 output.txt rb cstrin...

查詢指定檔案中特定字串賦值

include include include include include include include include static unsigned long get file size const char path return 1 static unsigned int print ...

Linux 查詢檔案中的特定字串

find 與 grep組合查詢 find name 檔案型別 xargs grep n 查詢內容 檔案型別可正規表示式通配,表示當前目錄下進行查詢,也可自由指定目錄.比如 find etc name properties xargs grep n cachesize 查詢 etc目錄下,包含cach...