Created
December 9, 2015 19:00
-
-
Save pprince/8fe98c94b64ca35c61d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To get the function: Sleep( time_in_milliseconds) | |
#include <windows.h> | |
void typewrite(char[] msg) { | |
for (int i = 0; i < strlen(msg); i++) { | |
cout << msg[i]; // print one character. | |
Sleep( rand_between(400, 1200) ); // pause for 400-1200 milliseconds. | |
} | |
cout << endl; | |
} | |
// In your code, you would call the function very simply, like so: | |
typewrite("Would you like to play a game?"); | |
// The function above can be declared equivalently as follows... | |
// (and, it usually would be written this way in real code, | |
// however, the explaination of why, involves more advanced | |
// topics; we'll cover pointers vs. arrays vs. C-style strings | |
// another day :) | |
void typewrite(const char *msg) { | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment