I know there are string tokenizers but is there an "int tokenizer"?
For example, I want to split the string "12 34 46" and have:
The C++ String Toolkit Library (StrTk) has the following solution to your problem:
#include
#include
#include "strtk.hpp"
int main()
{
{
std::string data = "12 34 46";
std::deque int_list;
strtk::parse(data," ",int_list);
}
{
std::string data = "12.12,34.34|46.46 58.58";
std::deque double_list;
strtk::parse(data," ,|",double_list);
}
return 0;
}
More examples can be found Here
Note: The parsing process is EXTREMELY fast and efficient, putting stdlib and boost based solutions to shame.