KABDRM
Programmer
- Jan 13, 2005
- 50
I have one file that ends on a line that has data
COUNT_OF_ATTEMPTS 4
595,13,"2008-10-20 04:40:15","2008-10-13 08:00:00"
294,11,"2008-10-21 04:47:15","2008-10-15 08:51:00"
637,14,"2008-10-22 04:45:15","2008-10-16 08:50:00"
504,7,"2008-10-23 08:30:15","2008-10-16 14:15:00"
123,45,"2008-10-24 16:15:15","2008-10-16 23:45:00"
637,14,"2008-10-25 14:00:15","2008-10-17 20:30:00"
595,13,"2008-10-26 16:15:15","2008-10-18 23:45:00"<-EOF here
and one that ends on the next line
COUNT_OF_ATTEMPTS 4
595,13,"2008-10-20 04:40:15","2008-10-13 08:00:00"
294,11,"2008-10-21 04:47:15","2008-10-15 08:51:00"
637,14,"2008-10-22 04:45:15","2008-10-16 08:50:00"
504,7,"2008-10-23 08:30:15","2008-10-16 14:15:00"
123,45,"2008-10-24 16:15:15","2008-10-16 23:45:00"
637,14,"2008-10-25 14:00:15","2008-10-17 20:30:00"
595,13,"2008-10-26 16:15:15","2008-10-18 23:45:00"
<- EOF here
How can I tell the difference between the two? I need to add a record_couint record to the end. In the first case, I count 8 records - that's good. This is how my file ends up:
COUNT_OF_ATTEMPTS 4
595,13,"2008-10-20 04:40:15","2008-10-13 08:00:00"
294,11,"2008-10-21 04:47:15","2008-10-15 08:51:00"
637,14,"2008-10-22 04:45:15","2008-10-16 08:50:00"
504,7,"2008-10-23 08:30:15","2008-10-16 14:15:00"
123,45,"2008-10-24 16:15:15","2008-10-16 23:45:00"
637,14,"2008-10-25 14:00:15","2008-10-17 20:30:00"
595,13,"2008-10-26 16:15:15","2008-10-18 23:45:00"
RECORD_COUNT:8
But in the second example, it still correctly counts 8 record but adds a blank line
COUNT_OF_ATTEMPTS 4
595,13,"2008-10-20 04:40:15","2008-10-13 08:00:00"
294,11,"2008-10-21 04:47:15","2008-10-15 08:51:00"
637,14,"2008-10-22 04:45:15","2008-10-16 08:50:00"
504,7,"2008-10-23 08:30:15","2008-10-16 14:15:00"
123,45,"2008-10-24 16:15:15","2008-10-16 23:45:00"
637,14,"2008-10-25 14:00:15","2008-10-17 20:30:00"
595,13,"2008-10-26 16:15:15","2008-10-18 23:45:00"
RECORD_COUINT:8
while (fgets(InString, 250, InFile) != NULL) {
if (strcmp(InString, "RECORD_COUNT", 12))
RecordCount++;
else
return(RC_FOUND_ADD_MODE);
}
fprintf(InputFile2, "\nRECORD_COUNT:%",RecordCount);
I'd either like it to count it as nine records or put the record count record after the last record and count 8 records.
Thank you!
COUNT_OF_ATTEMPTS 4
595,13,"2008-10-20 04:40:15","2008-10-13 08:00:00"
294,11,"2008-10-21 04:47:15","2008-10-15 08:51:00"
637,14,"2008-10-22 04:45:15","2008-10-16 08:50:00"
504,7,"2008-10-23 08:30:15","2008-10-16 14:15:00"
123,45,"2008-10-24 16:15:15","2008-10-16 23:45:00"
637,14,"2008-10-25 14:00:15","2008-10-17 20:30:00"
595,13,"2008-10-26 16:15:15","2008-10-18 23:45:00"<-EOF here
and one that ends on the next line
COUNT_OF_ATTEMPTS 4
595,13,"2008-10-20 04:40:15","2008-10-13 08:00:00"
294,11,"2008-10-21 04:47:15","2008-10-15 08:51:00"
637,14,"2008-10-22 04:45:15","2008-10-16 08:50:00"
504,7,"2008-10-23 08:30:15","2008-10-16 14:15:00"
123,45,"2008-10-24 16:15:15","2008-10-16 23:45:00"
637,14,"2008-10-25 14:00:15","2008-10-17 20:30:00"
595,13,"2008-10-26 16:15:15","2008-10-18 23:45:00"
<- EOF here
How can I tell the difference between the two? I need to add a record_couint record to the end. In the first case, I count 8 records - that's good. This is how my file ends up:
COUNT_OF_ATTEMPTS 4
595,13,"2008-10-20 04:40:15","2008-10-13 08:00:00"
294,11,"2008-10-21 04:47:15","2008-10-15 08:51:00"
637,14,"2008-10-22 04:45:15","2008-10-16 08:50:00"
504,7,"2008-10-23 08:30:15","2008-10-16 14:15:00"
123,45,"2008-10-24 16:15:15","2008-10-16 23:45:00"
637,14,"2008-10-25 14:00:15","2008-10-17 20:30:00"
595,13,"2008-10-26 16:15:15","2008-10-18 23:45:00"
RECORD_COUNT:8
But in the second example, it still correctly counts 8 record but adds a blank line
COUNT_OF_ATTEMPTS 4
595,13,"2008-10-20 04:40:15","2008-10-13 08:00:00"
294,11,"2008-10-21 04:47:15","2008-10-15 08:51:00"
637,14,"2008-10-22 04:45:15","2008-10-16 08:50:00"
504,7,"2008-10-23 08:30:15","2008-10-16 14:15:00"
123,45,"2008-10-24 16:15:15","2008-10-16 23:45:00"
637,14,"2008-10-25 14:00:15","2008-10-17 20:30:00"
595,13,"2008-10-26 16:15:15","2008-10-18 23:45:00"
RECORD_COUINT:8
while (fgets(InString, 250, InFile) != NULL) {
if (strcmp(InString, "RECORD_COUNT", 12))
RecordCount++;
else
return(RC_FOUND_ADD_MODE);
}
fprintf(InputFile2, "\nRECORD_COUNT:%",RecordCount);
I'd either like it to count it as nine records or put the record count record after the last record and count 8 records.
Thank you!