64,691
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
VOID CALLBACK onTimer(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
{
static int i = 0;
cout<<++i<<endl;
}
int main(int argc, char* argv[])
{
SetTimer(NULL,1,1000,onTimer);
MSG msg;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return 0;
}
#include <time.h>
void delay(int sec)
{
time_t start_time, cur_time; // 变量声明
time(&start_time);
do { time(&cur_time);
} while((cur_time - start_time) < sec );
}
#include<iostream.h>
#include <time.h>
using namespace std;
void delay(int sec)
{
time_t start_time, cur_time; // 变量声明
time(&start_time);
do {
time(&cur_time);
} while((cur_time - start_time) < sec );
}
void main()
{
cout<<"a"<<endl;
delay(5); // 滞后5秒
cout<<"b"<<endl;
}