• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

C++实现类似延时停顿的打字效果

c++ 搞代码 4年前 (2022-01-06) 15次浏览 已收录 0个评论

这篇文章主要介绍的是使用C++实现类似延时停顿的打字效果的代码,非常的简单,推荐给大家,有需要的小伙伴可以参考下。

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

 #include  #include  #include  #include       //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(sto<em style="color:transparent">来源[email protected]搞@^&代*@码网</em>ptimelong); printf("险"); system("color 46"); Sleep(stoptimelong); printf("世"); Sleep(stoptimelong); printf("界"); Sleep(stoptimelong); printf("!"); Sleep(stoptimelong); cout<<endl; getch(); return 0; }

演示图片

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

以上就是C++实现类似延时停顿的打字效果的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:C++实现类似延时停顿的打字效果
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址