zoukankan      html  css  js  c++  java
  • C++从文件中查找特定的字符串,并提取该字符串

    记录一个小技巧,使用C++从文件中查找特定标记的字符串,并提取该字符串。

    用到了CString的方法,十分的简单,用于数据分析很方便。

    这是我截取的压缩编码试验程序中的代码,通过这段代码可以提取X264输出的SSIM值

    FILE *fp_statfile=fopen("x264_output.txt","rb");
    CString filecontent("");
    //文件内容读入内存
    while(!feof(fp_statfile)){
    	filecontent.AppendChar(getc(fp_statfile));
    }
    //查找X264的SSIM数值
    //X264特征字符串
    CString featurestr("SSIM Mean Y:");
    //查找,返回字符串位置
    int paraloc=filecontent.Find(featurestr);
    CString parastr;
    //找到了的话
    if(paraloc!=-1){
    	//跳过特征字符串,提取5位
    	parastr=filecontent.Mid(paraloc+featurestr.GetLength(),5);
    	TRACE("%s
    ",parastr);
    }
    fclose(fp_statfile);

  • 相关阅读:
    touchMove VS touchCancel
    svg viewbox 作用
    reactjs reactLink
    放开linux下的端口
    运算符重载函数作为类成员函数和友元函数 (转)
    MBean和MXBean 区别
    transfer-encoding
    CSRF
    vue知识拓展
    居中
  • 原文地址:https://www.cnblogs.com/leixiaohua1020/p/3902181.html
Copyright © 2011-2022 走看看