windows控制台的定时器解决方法
windows控制台的定时器
#include "stdafx.h"
#include <windows.h>
#include<iostream>
using std::cout;
using std::endl;
#define myID 1000
void CALLBACK myfun(HWND, UINT,UINT_PTR nEventID,DWORD)
{
if(nEventID==myID)
cout<<"nihao"<<endl;
}
int main()
{
char c;
c=getchar();
if(c=='a')
{
::SetTimer(NULL,myID,2000,myfun);
}
c=getchar();
return 0;
}
谁试试我的代码,不对啊,这个在控制台下的定时器不行啊
帮忙修改一下吧
------解决方案--------------------
#include "stdafx.h"
#include <windows.h>
#include<iostream>
using std::cout;
using std::endl;
#define myID 1000
void CALLBACK myfun(HWND, UINT,UINT_PTR nEventID,DWORD)
{
if(nEventID==myID)
cout<<"nihao"<<endl;
}
int main()
{
char c;
c=getchar();
if(c=='a')
{
::SetTimer(NULL,myID,2000,myfun);
}
c=getchar();
return 0;
}
谁试试我的代码,不对啊,这个在控制台下的定时器不行啊
帮忙修改一下吧
------解决方案--------------------