请教延时循环的问题
各位朋友,想请教一个在c++ primer plus 上遇到的问题
编写延时循环的代码如下,主要用于实现程序延时间隔的功能:
// 延时循环.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include<iostream>#include<ctime>int _tmain(int argc, _TCHAR* argv[]){ using namespace std; cout<<"Enter the delay time,in seconds: "; float secs; cin>>secs; clock_t delay=secs*CLOCKS_PER_SEC; //转变为时钟滴答走针,转变为以秒计算 //clock_t是long的别名 相当于typedef long=clock_t; cout<<"starting\a\n"; clock_t start=clock(); while(clock()-start<delay) //直到时间结束 ; cout<<"done\a\n"; return 0;}while(clock()-start<delay) //直到时间结束 ;