Sleep Function

I have the sleep function working, but i was wondering if anyone could provide an example of it working in a loop for to make it appear one letter at a time as if someone was typing to the reader.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <cstring>
#include <iostream>
#include <windows.h>

const char *typed_text = "Hello World!";

int main()
{
  for(int idx = 0; idx < strlen(typed_text); ++idx)
  {
    std::cout << typed_text[idx];
    Sleep(500); // half-second between "typing" letters
  }
  std::cout << std::endl;
  return 0;
}


Thanks, Sadly i wont be able to try it out... Dropped my laptop and the tech crew are fixing it :/
Topic archived. No new replies allowed.