Break things into smaller steps. If you had two integers for the first line of the file such as count and sales, you might have this:
Code:
if ( fscanf(file, "%d %d%*c", &count, &sales) == 2 )
Then you might make a dynamic array of such records...
Code:
struct salesData *rec = malloc(count * sizeof *rec);
And then within each line you might read it something like this (between reading the first two strings and the last one)...
Code:
rec[i].value = malloc(sales * sizeof rec[i].value);
if ( !rec[i].value )
{
return 0; /* better cleanup should be done */
}
for ( j = 0; j < sales; ++j )
{
if ( fscanf(file, "%d", &rec[i].value[j]) != 1 )
{
return 0; /* better cleanup should be done */
}
printf("%d\n", rec[i].value[j]);
}