原创 MacOS sed對文件中匹配的行進行替換

例:替換 test.txt文件中 以"HHH"開頭的行 爲"hello world" linux: sed -i "/^HHH/c\hello world" test.txt -i: 表示直接對文件進行修改 macOS: sed -i

原创 統計字符串中子字符串的個數

使用strstr函數循環查詢字符串進行統計#include <stdio.h> #include <string.h> /** * 功能:統計母串p_str包含子串p_child_str的個數 * 入參:p_str:母串 * p