| | |
Need a new time delay function!
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 29
Reputation:
Solved Threads: 0
I need some help with delay functions,
First off, I know about windows.h, and the sleep(x) function.
But I can't use windows.h because it conflicts with my allegro.h causing my compiler to spew out errors from allegro.h everywhere.
Is there another function that i could use (Other than having to write out over 9000! loops to get the delay)?
First off, I know about windows.h, and the sleep(x) function.
But I can't use windows.h because it conflicts with my allegro.h causing my compiler to spew out errors from allegro.h everywhere.
Is there another function that i could use (Other than having to write out over 9000! loops to get the delay)?
0
#2 Oct 24th, 2009
Try using the <ctime> library:
http://www.cplusplus.com/reference/clibrary/ctime/time/
code for a 3 second delay:
http://www.cplusplus.com/reference/clibrary/ctime/time/
code for a 3 second delay:
C++ Syntax (Toggle Plain Text)
time_t start_time, cur_time; time(&start_time); do { time(&cur_time); } while((cur_time - start_time) < 3);
0
#3 Oct 24th, 2009
Here is another one, but it delays process.
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <ctime> using namespace std; void delay(int milliSec){ const unsigned int clk_strt = clock(); while(clock() - clk_strt < milliSec) continue; } int main(){ for(int i = 0; i < 5; i++) { delay(1000); cout<< (i+1) << " seconds has passed\n"; } }
1) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle. 2) Problem 2[b]solved by : jonsca
![]() |
Similar Threads
- delay function (PHP)
- Time Delay Code (Python)
- time delay during program execution (VB.NET)
- Time delay (Java)
- Need help writing a delay function in C++ (C++)
- Perl- How to call an event after a time delay (Perl)
- No "Data & Time" Function (Windows 95 / 98 / Me)
- 1 do while with 2 delay (how u do that??) (C++)
- Using time in programs (C++)
Other Threads in the C++ Forum
- Previous Thread: pulling numbers from a txt file and averaging it
- Next Thread: check status of variables
Views: 297 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll download dynamic encryption error file forms fstream function functions game givemetehcodez google graph gui iamthwee ifstream input int integer java lib library linkedlist linker linux loop looping loops map math matrix memory microsoft newbie news number output parameter pointer problem program programming project python random read recursion recursive reference return sort stream string strings struct studio system template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






