啊哈磊_编程从这里起步

标题: sleep()编译失败 [打印本页]

作者: code_007    时间: 2014-5-13 23:28
标题: sleep()编译失败
书本163页里面提到倒计时的程序,输入3 2 1 每秒输出一个,但是我按书本里面使用sleep函数却编译失败了,这是怎么回事呢?PS 用的是啊哈C编译器,代码如下:

#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("3");
sleep(1000);
printf("2");
sleep(1000);
printf("1");
system("pause");
return 0;
}


作者: 4399APPLE    时间: 2014-5-13 23:28
http://bbs.ahalei.com/forum.php?mod=viewthread&tid=3254
作者: 超神级    时间: 2014-5-14 00:24
{:soso_e117:}为什么又是这个..应该写份求助详解置顶求助.
作者: 超神级    时间: 2014-5-14 00:25
#include <stdio.h>
#include <stdlib.h>
#incldue<windows.h>
int main()
{
printf("3");
_sleep(1000);
printf("2");
_sleep(1000);
printf("1");
system("pause");
return 0;
}
作者: code_007    时间: 2014-5-14 15:17
最主要是没发现哪有搜索框来搜索论坛的帖子!{:soso_e101:}
作者: hqa1101    时间: 2014-5-15 19:06
sleep前加下划线
作者: StarX    时间: 2014-5-16 17:02
是Sleep();
S大写
作者: StarX    时间: 2014-5-16 17:03
书上这样说的

作者: cad20020601    时间: 2014-5-17 08:27
超神级 发表于 2014-5-14 00:24
为什么又是这个..应该写份求助详解置顶求助.

我的教程帖里面有写的。
作者: 119411    时间: 2014-5-17 22:27
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("3");
_sleep(1000);
printf("2");
_sleep(1000);
printf("1");
system("pause");
return 0;
}
作者: 青春    时间: 2014-5-24 14:08
在开头加上头文件     #include<windows.h>    就行了
作者: tt2005tuantuan    时间: 2014-5-25 20:53
没有#include <windows.h>
作者: tonny891104    时间: 2014-5-26 12:08
你这个sleep要首字母大写,最开头要加上#include<windows.h>




欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/) Powered by Discuz! X3.2