#1
  1. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    2
    Rep Power
    0

    Question Clear Screen + Sleep


    hello,
    I've started learning C# two weeks ago...so I'm like a newbie :)
    I was wondering how to clear screen in c?
    like
    Code:
    #include <stdio.h>
    void main ()
    {
                    int i;
    	printf ("Click 1 or 2: ");
    	scanf ("%d", &i);
    	if (i == 1)
    		{
    			//CLEAR SCREEN
    			printf ("ONE");
    		}
    	else
    		{
    			//CLEAR SCREEN
    			printf ("TWO");
    		}
    }
    And how to let the program sleep for like 5 sec?

    Thanks alot.:)
  2. #2
  3. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1511
    I think there is a more efficient way of doing it, but I know that system("cls"); will work in windows and system("clear"); in linux, as far as clearing the screan goes. I'd have to look up how to sleep, it's been too long.
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  4. #3
  5. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    There is a function called sleep() in both *nix and windows.
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,158
    Rep Power
    2222
    Originally posted by Onslaught
    There is a function called sleep() in both *nix and windows.
    Yes, both OSes' Cs have a sleep() function, but the parameter passed to it differs. In *nix, you tell it how many seconds to sleep, whereas in Windows you tell it how many milliseconds. When in doubt, do a short test program to time the sleep.

IMN logo majestic logo threadwatch logo seochat tools logo