thank you for quick replay
Quote:
Originally Posted by
ulillillia
Sleep is in milliseconds. For 2 seconds, you'd have Sleep(2000) instead. Using Sleep for much longer than than a few dozen milliseconds isn't really recommended because it can delay the closing of a program. You could try using a timer instead of Sleep.
yeah i tried but it saying,
undefined reference to `Sleep'
can u help me
thank you in advance
thank you for quick replay
Quote:
Originally Posted by
ulillillia
Sleep is Windows function. Include Windows.h to use it. Also note that it is "Sleep" with the capital "S" as the first letter.
What IDE/compiler do you use?
yeah!
can use it in unix plz.
thank you for quick replay
Quote:
Originally Posted by
ulillillia
Unfortunately, I don't know anything about Unix (never even seen it either) so I can't help you there. Short of using a basic timer system, such as the clock() function, I don't have any other alternatives. For proper use, you'd set a starting time and adjust the current time in a loop and until the difference is what you want, then continue on. Here's some pseudo code to give the general idea:
Code:
long StartTime, CurrentTime, EndTime;
StartTime = clock(); // set the starting time
CurrentTime = StartTime;
EndTime = StartTime + 2000; // 2000 milliseconds or 2 seconds
while (CurrentTime < EndTime) // loop until the ending time is reached
{
CurrentTime=clock();
}
how can i use this to wait 2 seconds in my program.
can you please help me
thank you in advance
thank you for quick replay
Quote:
Originally Posted by
swgh
According to my compiler help files:
C++ -> Sleep(2000);
C -> sleep(2000);
The capital makes a diiference
i am sorry to say it is not working.
i am using this sleep() in some other function (not in main())
is this any problem?
help me.
thank you in advacne
thank you for quick replay
Quote:
Originally Posted by
swgh
This waits for two seconds:
Code:
#include <stdio.h>
#include <windows.h> /*to define sleep()*/
int main ( void )
{
sleep(2000); /*wait 2 seconds*/
printf("Now you can see this\n");
getchar();
return 0;
}
in my program the sleep() is not belongs to main().
if i use sleep in main it is working fine but other than main it is not.
help me
thank you in advance
thank you for quick replay
Quote:
Originally Posted by
swgh
As longs you #include <windows.h> in your program before you use sleep() it should work. Does your compiler have the windows.h library? What compiler are you using, as it is OS an compiler specific
am doing my program in unix, i think this the problem.
thank you in advance