I was wondering, how am i able to split that kind of strings.
For example i have the following string: "80,8080,27001-27010,90"
I first want to split at the comma but if there is a minus in that substring i want to split it and get the difference between the two numbers by converting them via atoi(). The string i want to split is a list of ports, and i want to generate an array of integer with all ports enumerated. The strtok-function seems not suitable for this problem, is there any easy solution for this?
Using of strtok_r Example:
substr1 = strtok_r(portlist, delim1, &saveptr1);
while(substr1 != NULL){
substr2 = strtok_r(substr1, delim2, &saveptr2);
substr1 = strtok_r(NULL, delim2, &saveptr1);
}