所以我试图在屏幕上使文本滚动,例如;^h - 他 - HEL - 地狱 - 你好我的substr()不能按预期工作
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
string text = "Welcome to the Password Vault!";
int x;
for (x = 0; x < text.length(); x++) {
cout << text.substr(x,x);
_sleep(0100);
}
return 0;
}
它输出:
elccomome me toe to t to theto the Po the Pas the Passwthe Passworhe Password e Password Va Password VaulPassword Vault!assword Vault!ssword Vault!sword Vault!word Vault!ord Vault!rd Vault!d Vault! Vault!Vault!ault!ult!lt!t!! Process returned 0 (0x0) execution time : 1.961 s Press any key to continue.
我想输出:
Welcome to the password vault!
请帮帮我!
通常你需要发送一个字符来移动光标回到行的开头,例如:'\ r'。 – tadman
大家知道,C++ 11有一个标准的'std :: this_thread :: sleep_for'函数。并且0100是4的八进制文字,而不是100的值。 – chris
否#include'? –
CinCout