August 29th, 2003, 07:28 AM
Clear Screen + Sleep
I've started learning C# two weeks ago...so I'm like a newbie :)
I was wondering how to clear screen in c?
And how to let the program sleep for like 5 sec?
void main ()
printf ("Click 1 or 2: ");
scanf ("%d", &i);
if (i == 1)
August 29th, 2003, 08:08 AM
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.
August 29th, 2003, 08:37 AM
There is a function called sleep() in both *nix and windows.
August 29th, 2003, 09:48 AM
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.