You should try something like,
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
char b[] = "1.5, 2.5,3.5,4.5,5.5,6.5,7.5,,,10.5,11.5,12.5,,,15.5,16.5,17.5,18.5,19.5,20.5\n";
double c[21];
char *pptr = b;
b[strlen(b)-1]=',';
for (int i = 0; i < 21; i++) {
char *ptr = strchr(pptr, ',');
if (ptr) {
*ptr = 0;
c[i] = atof(pptr);
pptr = ptr + 1;
}
}
for (int i = 0; i < 20; i++){
fprintf(stdout, "%7.2lf", c[i]);
}
return 0;
}
-KR