嵌入式 打印在同一行printf行缓冲与退格使用技巧完成C语言倒计时
来源:互联网 发布:淘宝宝贝打折怎么设置 编辑:程序博客网 时间:2024/05/12 03:47
V2.00.000:
root@u12d32:/home/kongjun/work/hi_test/time_count_down# cat time_test.c #include<stdlib.h>#include <stdio.h>#include <time.h>int main(){ #if 1int bootdelay = 10;printf("Hit any key to stop autoboot: %2ds ", bootdelay);fflush(stdout);while(bootdelay > 0){sleep(1);--bootdelay;printf("\b\b\b\b%2ds ", bootdelay);fflush(stdout);}#endifprintf("\n");int i;printf(".................\n");for(i = 5; i > 0; i--){if(i == 5){printf("Wait %ds",i);fflush(stdout);sleep(1);}else{printf("\b\b%ds",i);fflush(stdout);sleep(1);}}printf("\n");return 0;}
运行效果图:
V1.00.001:
#include<stdlib.h>
#include <stdio.h>
#include <time.h>
int main()
{
#if 1
int bootdelay = 10;
printf("Hit any key to stop autoboot: %2d ", bootdelay);
fflush(stdout);
while(bootdelay > 0)
{
sleep(1);
--bootdelay;
printf("\b\b\b%2d ", bootdelay);
fflush(stdout);
}
#endif
int i;
printf(".................\n");
for(i = 5; i > 0; i--)
{
if(i == 5)
{
printf("Wait %d",i);
fflush(stdout);
sleep(1);
}
else
{
printf("\b%d",i);
fflush(stdout);
sleep(1);
}
}
return 0;
}
运行效果图:
0 0
- 嵌入式 打印在同一行printf行缓冲与退格使用技巧完成C语言倒计时
- C语言实现在控制台同一行覆盖刷新输出,以及'\b'退格控制字符的使用
- C下如何实现printf在同一行打印,如安装程序进程显示
- C语言在printf函数中打印'%'符号
- C语言退格\b的打印问题
- C语言学习记录之八printf函数使用技巧
- 嵌入式c语言中printf函数的使用(一)——将MCU的UART、IIC、或SPI与printf函数连接
- windows中控制台中在同一行打印信息
- python3.2 实现在同一行打印,实现进度条效果
- c语言中 printf的打印类型
- C语言 基础之printf打印输出
- c语言之printf打印类型
- c语言printf打印字符串颜色
- 关于C语言的printf打印对齐
- linux下C语言printf没有输出的问题(shell的行缓冲机制)
- printf() 与缓冲
- C语言之printf使用
- 两格div在同一行
- 用栈将中缀表达式转化为后缀表达式
- autoconf和automake的使用
- BUPT OJ88 最值问题
- android jni 自动注册
- 解决使用iBatis时initialize type alias异常问题
- 嵌入式 打印在同一行printf行缓冲与退格使用技巧完成C语言倒计时
- 流年依旧,只是散了曾经
- Sql时间函数
- 英语小语
- Ubuntu + Node.js + Mongodb开发环境搭建
- android适配各种分辨率的问题
- OpenGL 纹理单元 纹理目标 理解 glActiveTexture glBindTexture
- MapReduce简单实现基于物品的协同过滤算法
- JS 页面内容搜索,类似于 Ctrl+F功能的实现代码