Why am I having a problem with scope here. The record count is zero after the loop? BTW this is a code slice. Also if I use a static integer I get a proper record count, but I'm not sure why I would have to bother with a static counter since the structure is defined outside of the loop.
Code:
int main()
{
FILE *fptr;
counter_t counter = {0,0,1,1,NULL};
strcpy( counter.date, GetSystemDate() );
while( (buffer = GetRecord(fptr) ) != NULL)
{
counter.rec_count += 1;
//Break up COBOL datafile record for each salesman
GetCobolRecord(buffer,unedited_rec);
//build C style linked list out of extracted members
AddNode(&first,unedited_rec, key);
}
fclose(fptr); //close input file
printf("%d",counter.rec_count); exit(1);
}