Just separate them using 'find()' e.g.
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int split_text(string strIn, const char cDelim, vector<string>& vResult) {
int nPos = 0;
int nCount = 0;
int nFound;
string strToken;
while(1) {
nFound = strIn.find(cDelim,nPos);
if (-1 == nFound) {
strToken = strIn.substr(nPos,strIn.le
vResult.push_back(strToken
break;
}
strToken = strIn.substr(nPos,nFound - nPos);
nPos = nFound + 1;
++nCount;
vResult.push_back(strToken
}
return nCount;
}
int main () {
int n = split_text("ha/test6",'/',
cout << vResult[0] << endl;
cout << vResult[1] << endl;
}
That way, you can just separate them by accessing the individual index in the result array, i.e. 0 and 1.
Main Topics
Browse All Topics





by: sunnycoderPosted on 2007-09-18 at 18:47:50ID: 19917874
Hello jas_guis,
m/cppmulti map/index. html /en-us/lib rary/ 1ka6h ya8(VS.80) .aspx
Multimap looks good for this purpose
http://www.cppreference.co
http://msdn2.microsoft.com
First part of your string would form the key and the second part would be the value. Multimap allows you to store entries with duplicate keys.
Regards,
sunnycoder