Question: I have a comma delimited string in a C app that I'm putting together and I want to split it into an array of integer values.
The string could contain any number of comma delimited values so I also dont have an initial size for the array.

e.g. 

```
"345,3345,35,75,52,386"

```

and id like to do something like...

```
int parsedArray[] = parseString("345,3345,35,75,52,386");

```

This would be a breeze in java or c# but I think I'm a little out of my depth when it comes to C.
Any ideas of how to achieve this?

Answer: 
`p`is a pointer to your string

```
int parsedArray[1024];                                                     
int nb = 0;

while (nb < sizeof(parsedArray) && *p) {                                   
    parsedArray[nb++] = strtol(p, &p, 10);                                 
    if (*p != ',')                                                         
        break;                                                             
    p++; /* skip, */                                                       
}

```

`nb` is the number of parsed int
```
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main ()
{
  char str[] = "7,4200,4450, 500,1600, 500,550,600"; 

// Returns first token 
char *token = strtok(str, ","); 

int size=atoi(token);
int signal[size];
int i=0;

// Keep printing tokens while one of the 
// delimiters present in str[]. 
while (token != NULL) 
{ 
printf("%s\n", token); 
token = strtok(NULL, ","); 
if(token !=NULL){
signal[i]=atoi(token);
printf("%d --", signal[i]);
i=i+1;

}
} 

return 0; 
}

```