- Code: Select all
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
//standard function
void printTyper(string toPrint)
{
for (unsigned int a = 0; a<toPrint.length(); a++)
{
cout << toPrint[a];
Sleep(500);
}
}
//overloaded custom time version
void printTyper(int time, string toPrint)
{
for (unsigned int a = 0; a<toPrint.length(); a++)
{
cout << toPrint[a];
Sleep(time);
}
}
//main program call
int main()
{
string str1 = "my typewriter function"; // create a string called str1
printTyper(str1); // send str1 to the printTyper function and watch!!
cout << "\n\n";
printTyper(200, str1);// overloaded version where you can set the time delay
return 0;
}
its a pretty cool lil pair of functions
