Hello!
I have a string which may look like this:
(arne kristoffer)(1231232)(12.12.12)(asdasdf 12)
This is just an silly example, but never mind.
THe point is that i need to seperate the contents of the string into a string vector. This is my code (which of course doesn't work, if it had, I wouldn't have been posting here...):
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main ()
{
vector<string> vectorOfTags;
vectorOfTags.push_back("");
vectorOfTags.push_back("");
vectorOfTags.push_back("");
typedef vector<string>::size_type vecsz;
vecsz size = vectorOfTags.size();
int position = 0;
string *PointerToElement = &vectorOfTags[position];
string str("(56465)(Arne Kristoffer)");
for (int i=0; i < str.length(); i++)
{
if (str[i] != '(' || str[i] != ')')
*PointerToElement +=str[i];
else if (str[i] == ')')
position++;
}
cout << vectorOfTags[0] << endl;
cin.get();
return 0;
}
The result of this code, is that str is written to *PointerToELement without changing the position-variable, so str == VectorOfTags[0].
How could I change the code, so it would work? Please change my code instead of making an new one, since the reason why I do this is to learn, not only to make this program the fastest way posible.