syslog

#include <iostream>
#include <string>
#include <FSTREAM>
#include <SSTREAM>
#include <map>
using namespace std;
void main()
{
int i=0;
int posT=0,posD=0,pposD,sent,recv;
map<string,int> flowcount;
map<string,int> timecount;
ifstream ifile("testlog.txt");
string str,substr,str_tile,str_val,str_time,str_user,str_sent,str_recv;
while(ifile)
{
  getline(ifile,str);
posT=0;
posD=0;
while(posD<str.length())
{
posT=0;
pposD = posD;
posD = str.find(',',pposD+1);
substr =str.substr(pposD+1,posD-pposD-1);
posT=substr.find('=',posT+1);
str_tile = substr.substr(0,posT);
str_val = substr.substr(posT+1,substr.length()-posT-1);
if(str_tile=="time")
{
str_time = str_val.substr(0,5);
}
if (str_tile=="user")
{
str_user = str_val;
}
if (str_tile=="sent")
{
str_sent = str_val;
}
if (str_tile=="rcvd")
{
str_recv = str_val;
}
}
cout<<str_time<<" "<<str_user<<" "<<str_sent<<" "<<str_recv<<endl;


// cout<<str<<endl;
i++;
if (i==2)
{
// break;
}
cout<<i<<endl;
}
// for (int j=0;j<i;j++)
// {
// }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值