C++编程总结

来源:互联网 发布:淘宝客服不在分流组 编辑:程序博客网 时间:2024/06/04 18:07
  1. stringsteam重复使用同一string
    while (std::getline(files_stream, line))    {        std::istringstream ss(line);        string s;        vector<string> line_buf;        while (ss >> s)            line_buf.push_back(s);// 这里取出一行string的所有小string        ss.clear();        ss.str(line);        string name1, name2;        int id1, id2;        if (line_buf.size() == 3) {            ss >> name1 >> id1 >> id2;// 再次使用line这一string        }        else if (line_buf.size() == 4) {            ss >> name1 >> id1 >> name2 >> id2;        }    }
0 0
原创粉丝点击