I need to parse such string to list (or array) of ints:
"10; 20; 345; 45"
I though to do this so:
1 2 3 4 5 6 7 8 9 10 11 12 13
std::list<int> lst;
constchar *cur = str;
while (*cur) {
cur = skip_whitespaces(cur); // pointer to non whitespace char or '\0'
if (*cur == '\0')
break;
constchar *end = find_delim(cur + 1); // pointer to delimiter char or '\0'
int error;
int value = strtoint(cur, end, &error);
if (!error)
lst.push_back(value);
cur = end;
}
i've thought of using strstream or atoi (strtol), but this seems better.