0

How would i go about making a program wait before printing the next line? Keep in mind that i would like the next line to print automatically after a few seconds. Also if at all possible i would like to know how to make the text act like it is typing itself out on the screen.

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by Clinton Portis
1

#include<iostream>
#include<windows.h>

int main(){
   string str = "hello";
    cout<<str<<" ";
    Sleep(1000); //wait 1 second
     cout<<"world\n";

 return 0;
}

Edited by firstPerson: n/a

1
#include<windows.h>
#include<iostream>
using namespace std;

int main()
{
     char hello[11] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};

     for(int i=0, i<11, i++)
     {
          cout.put(hello[i]);
          Sleep(500);
     }
return 0;
}

Edited by Clinton Portis: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.