Hi,
Theres probably a really simple way of doing this but i cant work it out :\.
I have a string which contains this sort of data: "group1\r\ngroup2\r\ngroup3\r\n..."
I'm using \r\n as the splitting characters, and extracting each substring into a vector array of strings, although i don't know if thats the best structure to use? I cant use a standard array, as i don't know the number of elements.
Anyway heres the code i have so far (probably complete rubbish)
glist is the string with the data.
I know thats fairly wrong, but im unsure how to disregard the \r\n characters completely?Code:vector<string> group_list; int pos_a = 0; int pos_b = 0; for(int i = 0; i < glist.length(); i++) { pos_b = glist.find("\n", pos_b); string temp(glist.substr(pos_a, pos_b)); group_list.push_back(temp); pos_a = pos_b + 1; }
Maybe i would be better converting it to a char array and working with that?
Thanks for any advice,
Jack



LinkBack URL
About LinkBacks




CornedBee