注册 登录
编程论坛 VC++/MFC

关于计时器 有一处不懂 请帮忙

影随风 发布于 2013-11-15 13:44, 464 次点击
关于计时器 有一处不懂 请帮忙
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include<iostream>
using namespace std;

int Show(void)
{
  char str[100];
  time_t t;
  struct tm *lt;
  t = time(0);
  lt = localtime(&t);
  strftime(str,100,"%Y-%m-%d  %H:%M:%S ",lt);
  cout<<"前日期及时间是:"<<str;  
  return 0;
}

void sleep( clock_t wait )//  问题:::请详细解释这个函数的三段语句的作用
{
   clock_t goal;
   goal = wait + clock();
   while( goal > clock() ) ;
}


int main()
{
        while(1)
    {
    system("cls");
    Show();
    sleep(1000);
    }
        system("pause");
        return 0;
}
1 回复
#2
wp2319572013-11-15 14:54
重复发帖
1