i want to print the number of line printed in C++ by using Cfile. i want to write the number of line according to the date. for example in the same file it is written for two days ,
Nr date time code value 1 10/6/2019 09:10 220 55 2 10/6/2019 10:16 33 23 3 10/6/2019 10:50 55 11 1 11/6/2019 03:55 11 15 2 11/6/2019 08:22 18 20
everything is right except the line number
CString strDate, strYearShort, strTime;
strYearShort = (CString)Datum.year;
strYearShort = strYearShort.Right(2);
strDate = (CString)Datum.day + '.' + (CString)Datum.month + '.' + strYearShort;
strTime = (CString)Zeit.hour + ':' + (CString)Zeit.minute;
buf.Format(_T("%s\t%s\t%s\t%s\t%s\t%d\r\n\r\n"), strDate, strTime, (CString)number, (CString)cardnumber, value);
enter code hereif (CTime::GetCurrentTime().GetDay() != lastWriteDay) {
for (i = 1, i < 100, i++) {
int Nu = i,
}
}
else if (CTime::GetCurrentTime().GetDay() = lastWriteDay) {
Nu == 0;
or (i = 1, i < 100, i++) {
Nu = i,
}
}
Keep a variable of the last write date:
When writing a new line, compare last write date to the current date. If the dates are different, reset the line number.
Then you can update the number when you create the string:
Also, the example in your question does not have enough parameters. And it seems unnecessary to convert the integers to
CString. Just use the%dformat specifier.TODO: You might want to add some code that runs on startup that opens the file, reads the last line and parses the line to get the last write day. Then initialize
lastWriteDayto that. This is needed for when the app has quit and restarted on the same day for some reason.