Time between text

Ok I know the title is misleading but hold on. I want time between each line of text. For example I want it to say "Hi what's your name" and i type "al" then it says "Hi al" then instantly under it, it says "how old are you" (I know it's simple code but shut up) I want it to wait 2-3 seconds before it says "how old are you". How do I do that?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main(void)
{
    cout<<"Hi!\n";
    string name;
    cout<<"What is Your name?\n";
    getline(cin, name);
    cout<<"Well hello "<<name<<" nice to meet you"<<endl;
    string age;
    cout<<"How old are you?\n";
    getline(cin, age);
    cout<<"Oh you are "<<age<<" That's neat";
}
That depends on what platform you are using.

1
2
3
4
5
6
7
8
9
10
11
12
13
#ifdef __WIN32__
#include <windows.h> 
#else
#include <unistd.h>
#endif
void msleep(int milliseconds)
{
  #ifdef __WIN32__
  Sleep(milliseconds);
  #else
  usleep(static_cast<useconds_t>(milliseconds)*1000); //or use nanosleep on platforms where it's needed
  #endif
} 



Last edited on
Do you mean C++ an C or what windows platform (windows 7 64bit)?
Nevermind, I got it to work. Thanks for the help AbstractionAnon!
Topic archived. No new replies allowed.