用到了类string的length(), size(),find_first_of(),find_last_of(),substr(),push_back()函数
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
struct errorLog
{
string name;
string line;
int count;
};
errorLog createErrorLog(string name, string line)
{
errorLog log;
int nameSize = name.length();
int index = -1;
index = name.find_last_of('\\');
name = name.substr(index + 1);
log.name = name;
log.line = line;
log.count = 1;
return log;
}
void recordErrorLog(int number, errorLog log, vector<errorLog> & resu)
{
bool isRepeat = false;
for (int i = 0; i < resu.size(); i++)
{
if (resu[i].name == log.name && resu[i].line == log.line)
{
resu[i].count++;
isRepeat = true;
break;
}
}
if (isRepeat == false)