clock in ms_dos

This is a discussion on clock in ms_dos within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> #include <windows.h> #include <stdlib.h> using namespace std; // CLEAR THE SCREEN FUCTION void clrscr(void) { COORD coordScreen ...

  1. #1
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483

    clock in ms_dos

    Code:
    #include <iostream>
    #include <windows.h>
    #include <stdlib.h>
    using namespace std;
    
    // CLEAR THE SCREEN FUCTION
    void clrscr(void)
    {
        COORD                       coordScreen = { 0, 0 };
        DWORD                       cCharsWritten;
        CONSOLE_SCREEN_BUFFER_INFO  csbi;
        DWORD                       dwConSize;
        HANDLE                      hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        GetConsoleScreenBufferInfo(hConsole, &csbi);
        dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
        FillConsoleOutputCharacter(hConsole, TEXT(' '), 
                                   dwConSize, coordScreen, &cCharsWritten);
        GetConsoleScreenBufferInfo(hConsole, &csbi);
        FillConsoleOutputAttribute(hConsole, csbi.wAttributes, 
                                   dwConSize, coordScreen, &cCharsWritten);
        SetConsoleCursorPosition(hConsole, coordScreen);
    }
    
    //MAIN
    int main()
    {
    	//lol
    	int i = 1337;
    	while(i = 1337)
    	{
    		clrscr();
    		cout << "                                  DOS CLOCK" << endl;
    		cout << "\n                                      |";
    		Sleep(500);
    		
                    clrscr();
    		cout << "                                  DOS CLOCK" << endl;
    		cout << "\n                                      /" << endl;;
    		Sleep(500);
    
    		clrscr();
    		cout << "                                  DOS CLOCK" << endl;
    		cout << "\n                                      -";
                    Sleep(500);
    
    		clrscr();
    		cout << "                                  DOS CLOCK" << endl;
    		cout << "\n                                      \\" << endl;
    	}
    
    	system("PAUSE");
    	return 0;
    }
    Have fun

  2. #2
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168
    could i add that you could have just used
    Code:
    system("cls");
    :P

  3. #3
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    yeah, but on my compiler sometimes it gets screwy.. i like to use the way that is 100% sure to work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical Error in Clock program
    By SVXX in forum C++ Programming
    Replies: 0
    Last Post: 05-10-2009, 12:12 AM
  2. Outside influences on clock cycles? (clock_t)
    By rsgysel in forum C Programming
    Replies: 4
    Last Post: 01-08-2009, 05:15 PM
  3. Clock Troubles
    By _Nate_ in forum C Programming
    Replies: 22
    Last Post: 06-19-2008, 05:15 AM
  4. clock program
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-30-2007, 10:12 PM
  5. System clock
    By bazzano in forum C Programming
    Replies: 10
    Last Post: 03-27-2007, 10:37 AM

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