C++从文件中查找特定的字符串,并提取该字符串

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

记录一个小技巧,使用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\n",parastr);}fclose(fp_statfile);

           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

猜你喜欢

转载自blog.csdn.net/hffgjh/article/details/84195470
今日推荐