p3-150.cpp

来自「c++200源代码」· C++ 代码 · 共 25 行

CPP
25
字号
#include<iostream.h>
#include <time.h>

//时间延迟函数
void Dtime(int dt) {
    time_t current_time;
    time_t start_time;
    // 得到开始时间
    time(&start_time); 
    do 
    {
      time(&current_time);
    } 
    while ((current_time - start_time) < dt);
}

//main()函数的定义
void main(void)
{
    cout<<"The First information!"<<endl;
    cout<<"About to delay 5 seconds"<<endl;
    Dtime(5);
    cout<<"The Second information!"<<endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?