IVE TRYED ALOT EVERYTHING ON MY OTHR THREAD "I NEED A CODE" BUT NONE OF IT WORKS! WHATS THE CODE TO PAUSE LIKE FOR 5 SECONDS FOR EX.
THANK YOU
Printable View
IVE TRYED ALOT EVERYTHING ON MY OTHR THREAD "I NEED A CODE" BUT NONE OF IT WORKS! WHATS THE CODE TO PAUSE LIKE FOR 5 SECONDS FOR EX.
THANK YOU
#include <iostream.h>
#include <windows.h>
int main()
{
cout<<"Pauseing for 5 seconds"<<endl;
Sleep(5000); /* Notice capital 'S' in Sleep */
cout<<"Done pauseing"<<endl;
return 0;
}
Or you could try a little more elaborate variation:
#include<iostream>
#include<ctime> //or use time.h file
int main()
{
float secs = 5;
clock_t delay = secs * CLOCKS_PER_SEC; //convert to clock tics
clock_t start = clock();
while(clock() - start < delay)
;
return (0);
}
this allows more portability since you don't have to change delay when you change processor speed.
Edit: Also try using CLK_TCK or TCK_CLK instead of CLOCKS_PER_SEC.
That dont work im using a dos programQuote:
Originally posted by Dual-Catfish
#include <iostream.h>
#include <windows.h>
int main()
{
cout<<"Pauseing for 5 seconds"<<endl;
Sleep(5000); /* Notice capital 'S' in Sleep */
cout<<"Done pauseing"<<endl;
return 0;
}
_sleep(5); //which sleeps for 5 seconds (dos.h)
There have been about 4 reply's across your threads that should work on a DOS platform. So instead of just saying it doesn't work, and have people say the same things over and over. How about you
A) Describe what's not working (errors?)
B) Post your code (Use code tags)
C) Tell us what compiler you're using.
If you can't get a working answer first time after providing the board with that information, then you've got problems.
Yea sry ur right well it doesnt matter any more cause travellers code worked thx travellerQuote:
A) Describe what's not working (errors?)
B) Post your code (Use code tags)
C) Tell us what compiler you're using.