我有一个日志功能,在这里我有日志文件.现在,每次运行程序时,我都希望以前写入的文件不会被删除,并且应该附加当前数据(日志文件中有什么)
只是为了说清楚例如:我有一个日志文件logging_20120409.log,它每天保存时间戳.假设我运行我的项目,它会将当前时间戳写入其中.现在,如果我重新运行它,之前的时间戳将被替换.我不想要这个功能.我想要上一个时间戳和当前时间戳.
请帮忙
我有以下代码:
int main(int argc, char** argv) {
onelog a;
std::cout << "a new project";
//creates a file as varuntest.txt
ofstream file("C:\\users\\Lenovo\\Documents\\varuntest.txt", ios::app);
SYSTEMTIME thesystemtime;
GetSystemTime(&thesystemtime);
thesystemtime.wDay = 07;//changes the day
thesystemtime.wMonth = 04;//changes the month
thesystemtime.wYear = 2012;//changes the year
//creation of a filetimestruct and convert our new systemtime
FILETIME thefiletime;
SystemTimeToFileTime(&thesystemtime,&thefiletime);
//getthe handle to the file
HANDLE filename = CreateFile("C:\\users\\Lenovo\\Documents\\varuntest.txt",
FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
//set the filetime on the file
SetFileTime(filename,(LPFILETIME) NULL,(LPFILETIME) NULL,&thefiletime);
//close our handle.
CloseHandle(filename); …Run Code Online (Sandbox Code Playgroud) 我想知道netbeans中的c ++项目中的构建/清理和构建之间的区别有时候代码运行在其他地方运行它会产生一些错误,任何人都可以建议什么是更好的方式来了解ehen使用构建/清理和构建.
另外,如果你能告诉我简要介绍什么是测试和调试测试,那将有助于......
因为当我只是测试我的代码时,它没有提供所需的功能,当我进行调试测试时,我在某种程度上获得了功能
我想知道是否有比其他任何方法file.open();在<windows.h>
我需要制作一些东西(我称之为调度程序)来检查系统每分钟的时间,如果时间已经改变,假设它是17:52而下一个时刻是17:53,那么它在17:53调用一个函数logupdated
我如何使这个只是我不知道互斥锁和所有.
谢谢
我需要问一下,在netbeans 7.1.1中是否支持c ++ 11(使用libaries作为线程,chrono).
我有这个代码: -
#include<thread>
#include<chrono>
while(true)
{
std::this_thread::sleep_for(std::chrono::seconds(1)); <- there is an error at
"this_thread"
test4();
}
Run Code Online (Sandbox Code Playgroud)
实际上我正在努力制作在每分钟后调用此功能的东西(我的意思是当系统时间改变一分钟时)
谢谢