📜  c ++ splitlines - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:50.846000             🧑  作者: Mango

代码示例2
std::vector Loader::StringToLines(std::string string)
{
    std::vector result;
    std::string temp;
    int markbegin = 0;
    int markend = 0;

    for (int i = 0; i < string.length(); ++i) {     
        if (string[i] == '\n') {
            markend = i;
            result.push_back(string.substr(markbegin, markend - markbegin));
            markbegin = (i + 1);
        }
    }
    return result;
}