You will need to add safety checks to make sure the string follows the pattern yourself.
#include <string>
using std::string;
void parse(string line, string & l1, string & l2, string & l3)
{
// todo: insert your safety here; throw exceptions as necessary.
line.erase(0, 1);
auto space = line.find(' ');
l1 = line.substr(0, space);
line.erase(0, space + 1);
space = line.find(' ');
l2 = line.substr(0, space);
line.erase(0, space + 1);
l3 = std::move(line);
}
Usage:
string line;
// assign line
string l1, l2, l3;
parse(line, l1, l2, l3);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…