一个控制台程序中的日志产生程序(运用多线程)

王朝vc·作者佚名  2006-01-09
宽屏版  字体: |||超大  

在VC环境下,MFC console程序默认行为是单线程工作环境。我们在“工程-设置-C\C++”下的Code Generation选项中,将Use run-time library设为Multithreaded(多线程)。也可以在当前当前的Project Options 中加入“/MT”。(表示使用多线程版本的C runtime函数库)

#include #include #include using namespace std;void ReadTime(){ofstream f; CString str;int iNu = 0;while(1){ CTime ct = CTime::GetCurrentTime(); str.Format("%d年%d月%d日:%d:%d", (int)ct.GetYear(), (int)ct.GetMonth(), (int)ct.GetDay(), (int)ct.GetMinute(), (int)ct.GetSecond());f.open("w.txt", ios::app ); f

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有