C++实现类似延时停顿的打字效果
2015-03-31 10:00
676 查看
能够定位光标位置,改变屏幕设置
#include <iostream> #include <windows.h> #include <conio.h> #include <stdlib.h> //system函数所需头文件 #define stoptimelong 500 //Sleep函数以毫秒为单位,Sleep(500);表示停半秒 using namespace std; //跳到屏幕指定坐标 void gotoxy(int x,int y) { CONSOLE_SCREEN_BUFFER_INFO csbiInfo; HANDLE hConsoleOut; hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo); csbiInfo.dwCursorPosition.X = x; csbiInfo.dwCursorPosition.Y = y; SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition); } int main(void) { int x=14, y=5; gotoxy(x, y); printf("你好!"); Sleep(stoptimelong); system("color 10"); //调用控制台颜色管理命令,可以改变屏幕和字体的颜色 printf("欢"); Sleep(stoptimelong); printf("迎"); Sleep(stoptimelong); printf("来"); Sleep(stoptimelong); printf("到"); system("color 19"); Sleep(stoptimelong); printf("计"); Sleep(stoptimelong); printf("算"); Sleep(stoptimelong); printf("机"); system("color 37"); Sleep(stoptimelong); printf("冒"); Sleep(stoptimelong); printf("险"); system("color 46"); Sleep(stoptimelong); printf("世"); Sleep(stoptimelong); printf("界"); Sleep(stoptimelong); printf("!"); Sleep(stoptimelong); cout<<endl; getch(); return 0; }
演示图片
以上所述就是本文的全部内容了,希望能够对大家学习C++有所帮助。
您可能感兴趣的文章:
相关文章推荐
- C实现类似C++中的泛型效果
- C/C++ 实现类似Android JNI log库的效果
- 如何用Java实现类似c/c++指针效果
- 在Java中实现类似C/C++中#ifdef...#endif预编译宏的效果
- javascript 实现的类似hao123的多邮箱登录效果
- javascript 实现的类似hao123的多邮箱登录效果
- 今天摸索出一在bourne shell中实现类似数组效果的做法
- 如何用DataGrid实现类似DataList多列的效果
- Delphi中实现C++/Java类似静态变量的功能
- 类似 MSDN CSDN 左边导航树效果的实现! [JavaScript +
- 几行代码轻松搞定jquery实现flash8类似的连接效果
- 在(ASP+MSSQL)全文本搜索中如何用正则表达式实现类似百度的显示效果?
- 使用c++的成员指针实现类似Borland VCL组件的事件回调
- 类似 MSDN CSDN 左边导航树效果的实现! [JavaScript + ASP]
- 用C语言来实现的类似C++函数的重载特性-----void*指针闲谈
- 实现类似Google Earth的效果,做自己网站用户活动的3D效果原理
- 类似 MSDN CSDN 左边导航树效果的实现!
- JSP + JavaScript 实现类似 MSDN CSDN 导航树效果!
- 怎么样通过代码实现类似IE浏览器地址栏ComboBox的效果。
- Repeater绑定时实现类似DataList两列的效果