< dos.h>头文件在代码块中工作? [英] Does <dos.h> header file work in codeblocks?

查看:54
本文介绍了< dos.h>头文件在代码块中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dos.h 头文件的延迟功能在代码块中不起作用.它表明延迟函数未声明.以下链接包含以下程序.链接

The delay function of dos.h header file does not work in codeblocks. It shows that delay function is undeclared. the following link contains the program below. link

int main  ()
{ 
printf     (  "  This c program will exit in 10 seconds.\n");         
delay(10000);                         
return 0;
}

推荐答案

我也遇到了同样的问题&我用了这个功能

I was also having same problem & I used this function

 #include <time.h>
 void delay(int milliseconds)
 {
   long pause;
   clock_t now,then;

   pause = milliseconds*(CLOCKS_PER_SEC/1000);
   now = then = clock();
   while( (now-then) < pause )
     now = clock();
 }

如上所述,这确实使系统繁忙.我有更好的方法来完成此工作,并且适用于CodeBlocks.

edited :

As commented, this does make system busy. I have fund better way to do it, and works for CodeBlocks.

#include <windows.h>
 .
 .
 .
 Sleep(100); //sleep for 0.1 second
 .

这篇关于&lt; dos.h&gt;头文件在代码块中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆