Thread: Pause for just a bit...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    1

    Pause for just a bit...

    How can I pause my program for like 3 seconds then clear the screen then put some text up? Any help would be great, thanks i advanced....

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    Code:
    #include<iostream>
    #include<windows.h>
    
    using namespace std;
    
    int main(void){
    
    	cout<<"Here is my text";
    	Sleep(3000);
    	system("cls");
    
    	return(0);
    }
    Sleep is in milliseconds and system gets passed a char * which represents what you would type at the console.

  3. #3
    or you could do it the hard way using time.h and a while loop

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    317
    You mean:
    Code:
    #include <iostream>
    #include <windows.h>
    #include <ctime>
    
    using namespace std;
    
    int main(void){
    
                   float time_delay = 3;
                   cout<<"This is my text";
    
                   clock_t delay = time_delay*CLOCKS_PER_SEC;
                   clock_t start = clock();
                   while (clock() - start < delay);
    
                    system("cls");
                    return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bit processing in C
    By eliomancini in forum C Programming
    Replies: 8
    Last Post: 06-07-2005, 10:54 AM
  2. Porting from 32 bit machine to 64 bit machine!
    By anoopks in forum C Programming
    Replies: 10
    Last Post: 02-25-2005, 08:02 PM
  3. Light --- My Latest Game
    By TechWins in forum Game Programming
    Replies: 20
    Last Post: 08-14-2002, 05:15 AM
  4. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM
  5. bit conversions
    By wazilian in forum C Programming
    Replies: 4
    Last Post: 10-25-2001, 08:59 PM