@@ -235,20 +235,17 @@ void check(char filename1[], char filename2[])
235235 // Read dates from the second file and count the number of events on each date 
236236 while (fscanf(fp2, "%d\n", &day1) != EOF) 
237237 { 
238+   rewind(fp1); // Rewind the first input file to start reading from the beginning 
239+   count = 0; // Reset the event count for the current date 
240+ 238241  // Read events from the first file and check if they match the current date 
239242  while (fscanf(fp1, "%d, %[^\n]\n", &day2, events) != EOF) 
240243  { 
241244  if (day2 == day1) // If the event date matches the current date, increment the count 
242245  count++; 
243-   else // If the event date does not match the current date, print the count and reset it 
244-   { 
245-   printf("%d %d\n", day1, count); 
246-   count = 1; 
247-   break; 
248-   } 
249246  } 
247+   printf("%d %d\n", day1, count); // Print the current date and event count 
250248 } 
251-  printf("%d %d\n", day1, count); // Print the final count 
252249}
253250
254251int main()
0 commit comments