怎么用C语言每秒输出一个字符啊。在线等
c语言吧
全部回复
仅看楼主
level 1
zzzeee123 楼主
如题
2011年06月05日 00点06分 1
level 8
stdlib.h
_sleep(1000)
2011年06月05日 00点06分 2
level 8
windows.h
Sleep(1000)
2011年06月05日 00点06分 3
level 1
main(){ int i; for(i=65;i<=90;i++) {sleep(1);printf("%c",i);} }
2011年06月05日 01点06分 4
level 1
我用的TC,sleep单位是秒
2011年06月05日 01点06分 5
level 1
我不写头文件也能编译成功
2011年06月05日 01点06分 6
level 8
那并不是好习惯 换codeblocks吧
#include <time.h>
#include <stdio.h>
#include <string.h>
/* ==============
函数功能: 延时 函数, 单位为ms, 延时长短由 参数delay决定
================= */
void delayms(clock_t delay)
{
    clock_t start = clock();
    clock_t end;
    do {
        end = clock();
    } while( end - start < delay );
}
int main()
{
    char *hello = "Hello, world!\n";
    size_t len = strlen(hello);
    unsigned int i;
    for (i = 0; i < len; i++) {
        delayms( 1000 );
        putchar( hello[i] );
    }
    return 0;
}
2011年06月05日 01点06分 7
level 8
int main()改为int main(void)[我错了]
2011年06月05日 01点06分 8
level 1
clock的返回值是什么
2011年06月05日 01点06分 9
level 1
硬件滴答数吗什么是硬件滴答数呢
2011年06月05日 01点06分 10
level 1
硬件滴答数吗什么是硬件滴答数呢
2011年06月05日 01点06分 11
level 8
硬件滴答就像你的闹钟一样
闹钟滴滴答答60次是1分钟
硬件滴滴答答CLOCKS_PER_SEC次是1秒钟
CLOCKS_PER_SEC : clocks of per second(每秒钟的滴答数)
值一般为1000
2011年06月05日 01点06分 12
level 8
不过你用的TC2.0 是18.2
2011年06月05日 01点06分 13
level 1
懂了谢谢
2011年06月05日 01点06分 14
level 1
delay(1000)是延长多少时间应该是1000个滴答数,一秒滴答18.2次,那么应该是几十秒,这么推好象不对吧
2011年06月05日 01点06分 15
level 8
看12楼 13楼 另外看clock词条里的程序示例
TC2.0下 为18.2
VC++6.0下为 1000
1000ms = 1s
2011年06月05日 01点06分 16
level 1
tc中delay(1000)就是延时18.2毫秒对吗
2011年06月05日 02点06分 17
level 1
zzzeee123 楼主
学习了,学习了
2011年06月05日 04点06分 18
1