Код: Выделить всё
() - # ""
< /code>
e.g.:
10.03.2016 07:40:38: blacksheep (127.0.0.1:54444) #865 "(this can have text
over several lines
without ending marker"
10.03.2016 07:40:38: blacksheep (127.0.0.1:54444) #865 "A new line, just one without \n"
Код: Выделить всё
#include
#include
#include
#include
std::vector split(std::string str, char separator) {
std::vector result;
std::string::size_type token_offset = 0;
std::string::size_type separator_offset = 0;
while (separator_offset != std::string::npos) {
separator_offset = str.find(separator, separator_offset);
std::string::size_type token_length;
if(separator_offset == std::string::npos) {
token_length = separator_offset;
} else {
token_length = separator_offset - token_offset;
separator_offset++;
}
std::string token = str.substr(token_offset, token_length);
if (!token.empty()) {
result.push_back(token);
}
token_offset = separator_offset;
}
return result;
}
int main(int argc, char **argv) {
std::fstream fin("input.dat");
while(!fin.eof()) {
std::string line;
getline(fin, line, ';');
fin.ignore(80, '\n');
std::vector strs = split(line, ',');
for(int i = 0; i < strs.size(); ++i) {
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/35941171/c-parsing-a-log-with-split-but-one-entry-can-have-several-lines[/url]
Мобильная версия