Hi everyone, I need to declare a vector using string and then convert it to long int.
I wrote the following code but it is showing error.
1 2 3 4 5 6 7
string state = default("1 2 3 4 5");
std::vector<std::string> statesStr = cStringTokenizer(par("state")).asVector();
std::vector<long> statesPar;
for (auto k : statesStr) {
// How to convert the string to long?
statesPar.push_back(k.c_str()); // error
}
After searching, i found that it can be done using std::stol(), but i do not know how to code it.