Pause for just a bit...

This is a discussion on Pause for just a bit... within the C++ Programming forums, part of the General Programming Boards category; How can I pause my program for like 3 seconds then clear the screen then put some text up? Any ...

  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
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    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, 11: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, 06:15 AM
  4. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-26-2001, 12:45 AM
  5. bit conversions
    By wazilian in forum C Programming
    Replies: 4
    Last Post: 10-25-2001, 09:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21