去掉文本文件中含有某些字符串的行
来源:互联网 发布:网络弊大于利攻辩问题 编辑:程序博客网 时间:2024/05/23 01:16
#include <fstream>
#include <io.h>
#include <stdio.h>
#include <string>
using namespace std;
char filepath[MAX_PATH]={"sktdll.log"};
charbuf[1024]={0};//one line
char strmsg[]={"<msg>hb</msg>"};
TCHARg_tbuf[MAX_PATH*4];
void DebugMsg(const TCHAR* pszFormat, ...)
{
CTime now = CTime::GetCurrentTime();
_stprintf(g_tbuf, _T("/n[%s]"), now.Format("%Y-%m-%d %H:%M:%S"));
va_list arglist;
va_start(arglist, pszFormat);
_vstprintf(&g_tbuf[_tcslen(g_tbuf)], pszFormat, arglist);
va_end(arglist);
OutputDebugString(g_tbuf);
//logs(1,_T("%s"),g_tbuf);
}
ifstream infile;
infile.open(filepath);
if ( !infile.is_open() )
{
AfxMessageBox("ûÕÒµ½¸ÃÎļþ!");
return ;
}
string file_buf;
while( !infile.eof() )
{
memset(buf, 0, sizeof(buf));
infile.getline(buf, sizeof(buf));
//if ( buf[0] == 0 ) continue;
//if ( buf[0] == '#' ) continue;//comment
//if ( buf[0] == '/n' ) continue;
//if ( buf[0] == ' ' ) continue;
DebugMsg("%d :%s",strlen(buf) ,buf);
if (NULL==strstr(buf,strmsg))
{
file_buf.append(buf);
file_buf.append("/n");
}
}
infile.close();
if (file_buf.length()>0)
{
ofstream outfile;
outfile.open(filepath,ios::out);
outfile<<file_buf.c_str()<<endl;
outfile.close();
AfxMessageBox("ok!");
}else{
AfxMessageBox("error!");
}
- 去掉文本文件中含有某些字符串的行
- 提取海量文本文件中含有指定字符串的行
- js-字符串中去除含有的某些字符串
- 判断字符串中是否含有某些字段
- 批处理中如何判断参数中含有某些字符串?
- 批处理中如何判断参数中含有某些字符串?
- Linux查找某些文件中是否含有特定字符串
- 从zip 文件中找文件名含有某些字符串的文件/已经所含文件中含有某个字符串的文件//grep
- GET请求中参数含有某些特殊字符的处理
- pyhon-在原文本文件中替换某些特定的字符
- 删除字符串中某些特定的字符
- 设置字符串中某些字符的特殊效果
- unicode中含有双码元字符串的截取
- 获取字符串中含有的数字
- 去掉字符串中重复的子字符串
- 去掉字符串中匹配的字符串
- 字符串中含有双引号:
- pandas如何去掉、过滤数据集中的某些值或者某些行?
- 风险投资新模式
- sudo命令详解使用格式和方法
- 开复的心里话
- dorado过滤栏扩展
- 李开复简历
- 去掉文本文件中含有某些字符串的行
- 阿根廷1比3憾负巴西,南非之路蒙阴影
- LCD硬件及驱动开发
- 证言与贺词
- CFile文件操作
- 性格决定命运
- javaScript数字认识
- 用u盘做系统0基础教程
- js调用后台代码