Hey all,
Im fairly new with C++ and i havent been able to find an answer anywhere
else so far, so I'm asking here.
I'm looking for a way to do a time delay. What I mean by this is where the
code outputs a line to the screen (console app) and then waits say... 5
seconds and then prints out the next line.
Is this possible? Thanks in advance 5 1530
"Sargo" <sa******@chart ermi.net> wrote in message
news:sd******** ***********@fe0 5.lga... Hey all,
Im fairly new with C++ and i havent been able to find an answer anywhere else so far, so I'm asking here.
I'm looking for a way to do a time delay. What I mean by this is where
the code outputs a line to the screen (console app) and then waits say... 5 seconds and then prints out the next line.
Is this possible? Thanks in advance
I should also mention that this delay should delay only the function that
requires it and not pausing the entire program itself. I forgot to mention
that. Sorry.
On Sat, 8 Jan 2005 18:31:43 -0500, "Sargo" <sa******@chart ermi.net>
wrote: Hey all,
Im fairly new with C++ and i havent been able to find an answer anywhere else so far, so I'm asking here.
I'm looking for a way to do a time delay. What I mean by this is where the code outputs a line to the screen (console app) and then waits say... 5 seconds and then prints out the next line.
Is this possible? Thanks in advance
yes it is possible but is not a part of the C++ language - if you want
to have more general help I would suggest a forum like
microsoft.publi c.vc.language.
now to your question: in windows you can use the Sleep function
to suspend execution of the current thread.
// void Sleep( DWORD milliseconds );
Sleep( 5000 ); // wait 5 seconds
hth/ajk
--
"Those are my principles. If you don't like them I have others."
Groucho Marx.
"Sargo" <sa******@chart ermi.net> wrote... Im fairly new with C++ and i havent been able to find an answer anywhere else so far, so I'm asking here.
I'm looking for a way to do a time delay. What I mean by this is where the code outputs a line to the screen (console app) and then waits say... 5 seconds and then prints out the next line.
Is this possible? Thanks in advance
Yes, something like
cout << "a line" << endl;
time_t t1 = time(0), t2;
do
t2 = time(0);
while (_difference_in _seconds_(t1, t2) < 5);
cout << "the next line" << endl;
Now, you will somehow have to implement _difference_in_ seconds_
function, RTFM about 'localtime' function.
If you don't mind to be OS-specific, you can probably use some kind
of OS-specific way to introduce a delay. You will have to ask in
a newsgroup dedicated to your OS (whatever that is).
Victor
[ ... ] while (_difference_in _seconds_(t1, t2) < 5); cout << "the next line" << endl;
Now, you will somehow have to implement _difference_in_ seconds_ function, RTFM about 'localtime' function.
To me, it seems like difftime would be considerably more useful than
localtime.
--
Later,
Jerry.
The universe is a figment of its own imagination.
"Sargo" <sa******@chart ermi.net> wrote... "Sargo" <sa******@chart ermi.net> wrote in message news:sd******** ***********@fe0 5.lga... Hey all,
Im fairly new with C++ and i havent been able to find an answer anywhere else so far, so I'm asking here.
I'm looking for a way to do a time delay. What I mean by this is where the code outputs a line to the screen (console app) and then waits say... 5 seconds and then prints out the next line.
Is this possible? Thanks in advance
I should also mention that this delay should delay only the function that requires it and not pausing the entire program itself. I forgot to mention that. Sorry.
C++ virtual machine works in such way that the program is the _single_
sequence of statements executed _strictly_ in order. So, when it is time
to _execute_ your pause the whole virtual machine is going to delay any
further execution.
If you would like to discuss _multithreading _, try comp.programmin g.threads
or the newsgroup for your OS.
Victor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bart Nessux |
last post by:
am I doing this wrong:
print (time.time() / 60) / 60 #time.time has been running for many hours
if time.time() was (21600/60) then that would equal 360/60 which would
be 6, but I'm not getting 6 so I'm not doing the division right, any tips?
|
by: |
last post by:
I've trolled the lists, FAQs, and Net as a whole, but
can't find anything definitive to answer this.
We're looking for real-time graph capability (bar,
line, etc), so that we can display telemetry from a
robot system. There are a bunch of packages out
there, but many seem to provide only static graphs
(e.g. for scientific, financial data, etc). Does
anyone currently display real-time telemetry using
Python? Can anyone provide any...
|
by: David Stockwell |
last post by:
I'm sure this has been asked before, but I wasn't able to find it.
First off I know u can't change a tuple but if I wanted to increment a time
tuple by one day what is the standard method to do that?
I've tried the obvious things and haven't gotten very far.
I have a time tuple that was created like this:
aDate = '19920228'
x = time.strptime(aDate,"%Y%m%d")
|
by: David Graham |
last post by:
Hi
I have asked this question in alt.php as the time() function as used in
setcookie belongs to php - or does it belong equally in the javascript
camp - bit confused about that. Anyway, can anyone here put me straight on
the following:
I had a look at the time() function came across this:
"To clarify, it seems this function returns the time of the computer's clock
and does not do any timezone adjustments to return GMT, so you are...
|
by: Andrew Poulos |
last post by:
How do I convert a length of time, measured in seconds, into a "point in
time" type time interval or what's represented as: time (second,10,2)
The format is:
PS]] where:
y: The number of years (integer, >= 0, not restricted)
m: The number of months (integer, >=0, not restricted)
d: The number of days (integer, >=0, not restricted)
| |
by: Rebecca Smith |
last post by:
Today’s question involves two time text boxes each set to a different time
zone. Initially txtCurrentTime will be set to Pacific Time or system time.
This will change with system time as we travel across the country.
txtRaceTime will always be set to Central Time regardless of where we are in
the US.
At first I tried ‘Now() – “xx:xx:xx” but that produced an error. Anyway as
we approach the east coast the ‘minus’ would need to be a...
|
by: Rasputin |
last post by:
Is there any way to wait for a particular amount
of time without depending on machine cycles etc?
|
by: lucifer |
last post by:
hi,
if any body can tell me how to write a function that will create delay
according to the speed of processor
|
by: Ronald S. Cook |
last post by:
In a .NET Windows app, if I set somehting like the title of the form to
"MyApp" at run-time, will that make the app run slightly slower than if I
had set the title at design-time?
Thanks,
Ron
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |