Hi everybody,
I am awfully new to programming in C and all I have had to work with
so far have been tutorials that I've found online. In my searching,
however, I have not found a solution to a problem I have been facing.
Ideally, I would like the program to wait 5 minutes before executing
the rest of the code. Is there some way that I can use time.h and just
run a for loop that waits until 5 minutes has passed to continue down
the program?
Any help that you experts could give would be greatly appreciated.
Also, I apologize in advance if there is an obvious solution I have
overlooked.
Thanks,
Dave 19 3988 da*********@gma il.com said:
Hi everybody,
I am awfully new to programming in C and all I have had to work with
so far have been tutorials that I've found online. In my searching,
however, I have not found a solution to a problem I have been facing.
Ideally, I would like the program to wait 5 minutes before executing
the rest of the code. Is there some way that I can use time.h and just
run a for loop that waits until 5 minutes has passed to continue down
the program?
There *is* a way you can do that in standard C, yes - but it's not a very
good way. It will work, but it will be a "busy" loop, taking up valuable
processing time. You do it like this:
#include <stddef.h>
#include <time.h>
void delay(unsigned int seconds)
{
time_t start = time(NULL);
double diff = 0.0;
while(diff < seconds)
{
diff = difftime(time(N ULL), start);
}
return;
} /* to delay for five seconds, call delay(5) */
but, like I said, this is not a very good way to do it. Unfortunately, it's
the best way available in standard C. Your C implementation is very likely
to provide a library function that can do basically the same job except
that the processor will be released to do other things. For example, Win32
provides Sleep(), and POSIX(?) provides sleep() and usleep(). If you want
to discuss such functions, I suggest comp.os.ms-windows.program mer.win32
and comp.unix.progr ammer respectively.
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
On Dec 24, 10:34 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
Ideally, I would like the program to wait 5 minutes before executing
the rest of the code. Is there some way that I can use time.h and just
run a for loop that waits until 5 minutes has passed to continue down
the program?
There is a sleep function in the GNU C library. http://www.gnu.org/software/libc/man....html#Sleeping
Regards,
Ivan Novick http://www.0x4849.net
Ivan Novick wrote:
Richard Heathfield <r...@see.sig.i nvalidwrote:
>>Ideally, I would like the program to wait 5 minutes before executing the rest of the code. Is there some way that I can use time.h and just run a for loop that waits until 5 minutes has passed to continue down the program?
There is a sleep function in the GNU C library.
http://www.gnu.org/software/libc/man....html#Sleeping
GNU C is not ISO standard C. Extensions are off-topic here. There
would have been no objection if you had made this clear.
--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee, Frohe Weihnachten
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home .att.net>
--
Posted via a free Usenet account from http://www.teranews.com
In article <47************ ***@yahoo.com>,
CBFalconer <cb********@mai neline.netwrote :
>Ivan Novick wrote:
....
>There is a sleep function in the GNU C library.
http://www.gnu.org/software/libc/man....html#Sleeping GNU C is not ISO standard C. Extensions are off-topic here. There would have been no objection if you had made this clear.
Wanna bet?
No matter how many caveats he had included, someone (probably you or one
of your cabal) would still have had a go at it.
It's what we do here. The point is that at least one someone would have
found it too hard to resist. The egoboo, ya know...
"CBFalconer " <cb********@yah oo.comschrieb im Newsbeitrag
news:47******** *******@yahoo.c om...
Ivan Novick wrote:
>Richard Heathfield <r...@see.sig.i nvalidwrote:
>>>Ideally, I would like the program to wait 5 minutes before executing the rest of the code. Is there some way that I can use time.h and just run a for loop that waits until 5 minutes has passed to continue down the program?
There is a sleep function in the GNU C library.
http://www.gnu.org/software/libc/man....html#Sleeping
GNU C is not ISO standard C. Extensions are off-topic here. There
would have been no objection if you had made this clear.
He did make it very clear that this is in the GNU C library. How could it
possibly get any clearer?
Bye, Jojo
Ivan Novick said:
On Dec 24, 10:34 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
Ideally, I would like the program to wait 5 minutes before executing
the rest of the code. Is there some way that I can use time.h and just
run a for loop that waits until 5 minutes has passed to continue down
the program?
No, I didn't write any of that. I merely quoted it. It was written by the
OP.
There is a sleep function in the GNU C library.
Yes. My reply (which you snipped) mentioned sleep().
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
"Joachim Schmitz" <no*********@sc hmitz-digital.dewrite s:
"CBFalconer " <cb********@yah oo.comschrieb im Newsbeitrag
news:47******** *******@yahoo.c om...
>Ivan Novick wrote:
>>Richard Heathfield <r...@see.sig.i nvalidwrote:
Ideally, I would like the program to wait 5 minutes before executing the rest of the code. Is there some way that I can use time.h and just run a for loop that waits until 5 minutes has passed to continue down the program?
There is a sleep function in the GNU C library.
http://www.gnu.org/software/libc/man....html#Sleeping GNU C is not ISO standard C. Extensions are off-topic here. There would have been no objection if you had made this clear.
He did make it very clear that this is in the GNU C library. How could it
possibly get any clearer?
The GNU C library also has a strlen function. http://www.gnu.org/software/libc/man...ng-Length.html
--
Keith Thompson (The_Other_Keit h) <ks***@mib.or g>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Keith Thompson" <ks***@mib.orgs chrieb im Newsbeitrag
news:87******** ****@kvetch.smo v.org...
"Joachim Schmitz" <no*********@sc hmitz-digital.dewrite s:
>"CBFalconer " <cb********@yah oo.comschrieb im Newsbeitrag news:47******* ********@yahoo. com...
>>Ivan Novick wrote: Richard Heathfield <r...@see.sig.i nvalidwrote:
>Ideally, I would like the program to wait 5 minutes before >executin g the rest of the code. Is there some way that I can use >time.h and just run a for loop that waits until 5 minutes has >passed to continue down the program?
There is a sleep function in the GNU C library.
http://www.gnu.org/software/libc/man....html#Sleeping
GNU C is not ISO standard C. Extensions are off-topic here. There would have been no objection if you had made this clear.
He did make it very clear that this is in the GNU C library. How could it possibly get any clearer?
The GNU C library also has a strlen function. http://www.gnu.org/software/libc/man...ng-Length.html
So what? Does that make strlen off topic here?
Bse, Jojo
Hey everybody,
I attempted to use the sleep() function, but I am using Pelles C
compiler and unistd.h has sleep() commented out. I guess I will have
to figure out something else to try to get my program to pause.
Thanks for your help everyone,
Dave This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ryan Spencer |
last post by:
Hello again Everyone,
I spent a small amount of time recently writing a program that "blinks"
text. I did it by first having a user input a string,
sys.stdout.write-ing the string, then backing up judging by the number of
characters the string has, re-stdout's over it with blank spaces (judged
again by it's character count), and then backs up again in a never ending
while loop. It keeps each blink .5 seconds spaced as well, and all in...
|
by: dan |
last post by:
I need help in figuring out what to do for this program, it is a
program that reads book id, unit price, book purchased, book sold,
book returned, and city(respectively). It is a control break program
that prints a report for each city on a separate screen with a total,
then at the end it has a grand total. It prints to the screen and an
output file.
Input file looks like (the char is the city)
200 1.40 30 13 1 B
201 7.50 13 ...
|
by: Thomas Matthews |
last post by:
Is there anything technically wrong with the code below?
I compiled it with g++ 3.3.1 and it executes with no errors.
I compiled it with bcc32 5.6 and it executes with "This
program has performed an illegal operation."
I am running this on Windows 98 platform.
{If not, I'll post this issue to a Borland newsgroup.}
#include <iostream>
#include <fstream>
|
by: Amit Nath |
last post by:
Hi!
I am running a C program and need to pause the program and change some
of the variables. Is there any function that checks if there is a
character in the Standard Input Buffer, else the program keeps on
running. Can someone please help me on that.
AN
|
by: wayne hamilton |
last post by:
I'm having a problem Interacting with Command Line programs. I can read and
write anything I want as long as I don't have to interact with a process
once it's started. Originally I had been calling 'test.bat' directly, and in
the latest incarnation (below) I am starting up cmd.exe and then writing the
commands I want to execute to the command line that way.
My problem is that I need to know if a program is waiting for input. In my
batch...
| |
by: FaroeIslander |
last post by:
Hello all.
I am currently working on a program in VB.NET where the user can run a
"hidden" DOS program and as the program is running the user can see how many
computations have been performed by the program. To do this i am "piping"
information back and forth between DOS and VB.NET.
I also want to make the user able to abort and/or pause the computations in
DOS. My question is how i can abort/pause a running DOS program. The only way
to...
|
by: Lloydm |
last post by:
I've used the command "pause" in batch files which works ok but I guess it's applied dirrently in c++.
Using Dev C++ 4.0 and the following is my code
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
main(){
|
by: greg |
last post by:
Hi,
Can anyone help me with the following issue:
How can I pause the execution of a program until a given file is
created (by another process) in a specified directory?
Any ideas would be highly appreciated.
Thanks!
|
by: Break2 |
last post by:
I am trying to write a simple program which asks a user to enter 5 integers after which the average will be computed and written to the screen. That simple.
However I want to do it according to a standard I used before to write a program which asked a user to enter the current year and his birthyear after which the current age of the user was computed and written to the screen.
I got some help with the second program from some of you, thanks...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |