It looks neat..but i think the "++ptr" should be inside else.
I tried the below and it works
char lname[32];
char fname[32];
char start[5];
..
char *subs[13]={lname,fname,start..};
while (fgets(buf, MAX_LINE_LEN+1, fpsub))
{
ptr=buf;
for(i=0;i<12;i++)
{
if(sscanf(ptr,"%[^:]%n", subs[i], &n) == 1 )
{
ptr += n + 1;
}
else
{
++ptr;
strcpy(subs[i],"NULL");
}
}
The fields in the rows vary greatly in size.
Max is 33 bytes and minimum is just one byte..
Anyway i have to assign 'NULL' in case of empty field so minimum field length is '5'.
with using 2 dimensional array i think we have to use the maximum field length to every field(if i understand correctly!!)
Let me try to write a empty string instead of NULL for empty fields.
that way i can declare even 2 byte array for 1 byte fields.
Do you think this is a good way to go??