split function for C++
c++, split, string, templates
Solution
Use Boost::tokenizer as it does what you want to do. From the manual:
// simple_example_1.cpp
#include<iostream>
#include<boost/tokenizer.hpp>
#include<string>
int main(){
using namespace std;
using namespace boost;
string s = "This is, a test";
tokenizer<> tok(s);
for(tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg){
cout << *beg << "\n";
}
}
Problem
Is there a split type function for C++ similar to Java? I know of ignore, but I don't quite understand it, and how it'll work for my case. My input is: ``` { item = ball book = lord of the rings movie = star wars } ``` My input given is an `<attribute>` = `<value>` and I have to store the two in different strings, or integers (depending on the value, for example, if its a number, use an integer).