栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

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

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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(stoptimelong);
  printf("险");
  system("color 46");
  Sleep(stoptimelong);
  printf("世");
  Sleep(stoptimelong);
  printf("界");
  Sleep(stoptimelong);
  printf("!");
  Sleep(stoptimelong);
  cout<

演示图片

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/65205.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号