I tried what you suggested and it won't compile. My array is declared as follows:
Code:
typedef struct start_info
{
char name[20];
int age[10];
}start_info;
start_info start[40];
I like the idea of keeping count of the number of names. I am using sccanf to store the names into the array. Is there a way to keep count of each name? My code that stores the names looks like this:
Code:
while (fgets(line,sizeof(line),f)!=NULL)
{
int n;
char *p = line;
pc = strstr (line,"AGES");
if (pc != NULL)
{
//printf("%s\n", line);
break;
}
while ( i < 20 && sscanf( p, "%s%n", start[i].name, &n) == 1 )
{
p += n;
i++;
}
}