I'm using Borland C++. I tried a few different things that I found here on the board, faq etc. But none of them work. Do you know how to delay, or make a program wait, but not for system time eithor I mean regular time.
I'm using Borland C++. I tried a few different things that I found here on the board, faq etc. But none of them work. Do you know how to delay, or make a program wait, but not for system time eithor I mean regular time.
you may use this
for (i=0;i<1000;i++);
i wish it works
Doesn't Borland have a Sleep(milliseconds) function?
I'm pretty sure it does. I don't know what header it's in though. Sorry.
Or you could roll your own-
Code:#include <cstdio> #include <ctime> void Sleep(int MilliSeconds) { // CLOCKS_PER_SEC / 1000 gives the number of system clock ticks per millisecond int TicksPerMilliSec = CLOCKS_PER_SEC / 1000; // Set the desired looping time value int LoopingTime = clock() / TicksPerMilliSec + MilliSeconds; // loop until the desired amount of milliseconds has passed while(LoopingTime > clock() / TicksPerMilliSec) { // just keep looping } } int main() { Sleep(2000); printf("Program running for %d seconds\n", clock() / CLOCKS_PER_SEC); Sleep(2000); printf("Program running for %d seconds\n", clock() / CLOCKS_PER_SEC); return 0; }
Er... Borland C has always had delay (millisecs).
Current Setup: Win 10 with Code::Blocks 17.12 (GNU GCC)
It does have one called Sleep(milliseconds). The header should be in one of the following: conio.h, windows.h, dos.h, stdlib.h, or stdio.h.
I've used them but not a single one works...
The bigger function works... Thanx
u can use
_sleep(avalue);