【发布时间】:2019-06-18 11:56:17
【问题描述】:
我想使用 Cfile 打印在 C++ 中打印的行数。 我想根据日期写行数。 例如在同一个文件中写了两天,
Nr 日期时间码值 1 2019 年 10 月 6 日 09:10 220 55 2 2019 年 10 月 6 日 10:16 33 23 3 2019 年 10 月 6 日 10:50 55 11 1 2019 年 11 月 6 日 03:55 11 15 2 2019 年 11 月 6 日 08:22 18 20除了行号,一切都正确
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,
}
}
【问题讨论】:
-
代码和示例输出似乎不匹配。你能澄清一下你想要做什么吗?
-
这是一个小例子,输出有更多信息。我的问题是如何打印行数并在第二天从 1 开始
-
你是说你想要一个
4而不是1在输出的最后一行? -
1 在新的日期,就像我写的一样
-
听起来很简单。只需保留上次写入时间/日期的变量。写入新行时,将上次写入时间与当前时间进行比较。如果日期不同,请重置行号。