@@ -235,20 +235,17 @@ void check(char filename1[], char filename2[])
235
235
// Read dates from the second file and count the number of events on each date
236
236
while (fscanf(fp2, "%d\n", &day1) != EOF)
237
237
{
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
+
238
241
// Read events from the first file and check if they match the current date
239
242
while (fscanf(fp1, "%d, %[^\n]\n", &day2, events) != EOF)
240
243
{
241
244
if (day2 == day1) // If the event date matches the current date, increment the count
242
245
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
- }
249
246
}
247
+ printf("%d %d\n", day1, count); // Print the current date and event count
250
248
}
251
- printf("%d %d\n", day1, count); // Print the final count
252
249
}
253
250
254
251
int main()
0 commit comments