By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,967 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,967 IT Pros & Developers. It's quick & easy.

what is funtion for delay in VC

P: n/a
hi
i need to insert delay in my program what function should i use
the old delay is not supported by the VC6

Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
In article <11**********************@f14g2000cwb.googlegroups .com>,
lucifer <um**********@gmail.com> wrote:
i need to insert delay in my program what function should i use
the old delay is not supported by the VC6


As you posted to comp.lang.c, our answer will be in terms of
the features provided by standardized C. Anything VC6 should
be discussed in a newsgroup appropriate for VC6.

Standard C provides no delay functions at all. None. Not one.
Zero. Zippo. Null set.

The closest you can get to a delay function in C is a loop that changes
the value of a volatile variable that has external linkage.

If you looped changing a local variable, there is the risk that the
optimizer would optimize the loop out completely, but for volatile
variables it should assume that there might be -some- other
mechanism that might change the value, so it shouldn't optimize
out the loop.

This is, of course, a very crude delay mechanism, and the duration
of the delay will likely vary from run to run, and if you have
multiple calls within the same program you shouldn't expect that they
would delay by the same duration.

If you want any kind of accuracy or repeatability or calibration
of a delay duration, you will need to use some implementation-
dependant call that is outside the scope of the C standard.
--
Goedel's Mail Filter Incompleteness Theorem:
In any sufficiently expressive language, with any fixed set of
email filtering algorithms, there exists at least one spam message
which the algorithms are unable to filter out.
Nov 15 '05 #2

P: n/a
you can use Sleep(int miliseconds) in VC++ , note the capital 'S'

Nov 15 '05 #3

P: n/a
"lucifer" <um**********@gmail.com> writes:
i need to insert delay in my program what function should i use
the old delay is not supported by the VC6


See question 19.37 in the C FAQ. It discusses delays with sub-second
resolution, but it's applicable to delays in general. Quick summary:
there's no portable way to do it, and we don't discuss non-portable
solutions here.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #4

P: n/a
Walter Roberson wrote:
In article <11**********************@f14g2000cwb.googlegroups .com>,
lucifer <um**********@gmail.com> wrote:
i need to insert delay in my program what function should i use
the old delay is not supported by the VC6


As you posted to comp.lang.c, our answer will be in terms of
the features provided by standardized C. Anything VC6 should
be discussed in a newsgroup appropriate for VC6.

Standard C provides no delay functions at all. None. Not one.
Zero. Zippo. Null set.

The closest you can get to a delay function in C is a loop that changes
the value of a volatile variable that has external linkage.


<snip>

You could also do a loop using the functions in time.h, although you
have no guarantee what precision you will get. Of course, I would not
want to use a program that made use of either of these methods so asking
in a microsoft group would indeed be the best course for the OP.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #5

P: n/a
On 1 Oct 2005 10:01:50 -0700, in comp.lang.c , "Sandeep"
<sa************@gmail.com> wrote:
you can use Sleep(int miliseconds) in VC++ , note the capital 'S'


There's no function of that name in C. Please don't answer offtopic
questions in CLC.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 15 '05 #6

P: n/a
lucifer wrote on 01/10/05 :
hi
i need to insert delay in my program what function should i use
the old delay is not supported by the VC6


There is no standard answer.

<OT>
Sleep() (include <windows.h>)
</>

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

I once asked an expert COBOL programmer, how to
declare local variables in COBOL, the reply was:
"what is a local variable?"
Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.