标签:
平常做项目都是用java语言,搞毕业论文的时候,需要用到opengl,而opengl和c++的关系很密切并且参考资料也比较丰富,在程序开发的过程用中到了字符串分割,查api竟然没有找到自带的split函数,在这里记录一下c++字符串分割方法。static void split(const string& src, const string& separator, vector<string>& dest) { string str = src; string substring; string::size_type start = 0, index; do { index = str.find_first_of(separator,start); if (index != string::npos) { substring = str.substr(start,index-start); dest.push_back(substring); start = str.find_first_not_of(separator,index); if (start == string::npos) return; } }while(index != string::npos); //the last token substring = str.substr(start); dest.push_back(substring); }
标签:
原文地址:http://blog.csdn.net/wj512416359/article/details/43154639