手机
当前位置:查字典教程网 >编程开发 >C语言 >C++实现类似延时停顿的打字效果
C++实现类似延时停顿的打字效果
摘要:能够定位光标位置,改变屏幕设置#include#include#include#include//system函数所需头文件#defines...

能够定位光标位置,改变屏幕设置

#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++实现类似延时停顿的打字效果1

以上所述就是本文的全部内容了,希望能够对大家学习C++有所帮助。

【C++实现类似延时停顿的打字效果】相关文章:

用C语言实现单链表的各种操作(二)

用c语言实现2000内既能被3整除又能被7整除的个数

深入C++四种强制类型转换的总结

使用map实现单词转换的实例分析

用c++实现x的y次幂的代码

C++中函数模板的用法详细解析

C++指向类成员函数的指针详细解析

用C++实现strcpy(),返回一个char*类型的深入分析

C++实现strcmp字符串比较的深入探讨

C++实现正态随机分布的方法

精品推荐
分类导航