Added the type in to the print
This commit is contained in:
parent
b7ad0fbb6c
commit
5855b37c6e
|
@ -1,5 +1,7 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Print{
|
||||
|
@ -12,5 +14,6 @@ class Print{
|
|||
};
|
||||
void printl(string text);
|
||||
void println(string text);
|
||||
|
||||
static void type(string text);
|
||||
|
||||
};
|
||||
|
|
|
@ -7,3 +7,20 @@ void Print::printl(string text){
|
|||
void Print::println(string text){
|
||||
cout << text << endl;
|
||||
}
|
||||
|
||||
void Print::type(string text){
|
||||
int a = text.size();
|
||||
char* charArray = new char[a+1];
|
||||
strcpy(charArray, text.c_str());
|
||||
int i = 0;
|
||||
int time = 300;
|
||||
|
||||
while(i < a+1){
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(time));
|
||||
cout << charArray[i] << flush;
|
||||
i++;
|
||||
|
||||
}
|
||||
cout << endl;
|
||||
delete[] charArray;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue