Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Time Delays?

StrobeStrobe Member Posts: 3
[b][red]This message was edited by Strobe at 2002-7-30 15:47:34[/red][/b][hr]
How does one implement a simple 3 second time delay? I've looked in alot of places on the web and one that seemed the easiest to use would be the supposed sleep() function of time.h But according to the compiler I'm using (Visual C++ 6.0) this function does not exist. Any help you could offer?

Comments

  • Null and VoidNull and Void Member Posts: 1,202
    : How does one implement a simple 3 second time delay? I've looked in
    : alot of places on the web and one that seemed the easiest to use would
    : be the supposed sleep() function of time.h But according to the
    : compiler I'm using (Visual C++ 6.0) this function does not exist. Any
    : help you could offer?

    The 'sleep' function is not part of the ANSI/ISO standard (it is part of POSIX, though), so don't be surprised that it's not there. Since you say you're using MSVC, which can only produce Win32 executables, you should be able to use Sleep which will sleep for at least some amount of milliseconds (if you pass '0' it is an undocumented feature that it yeilds the thread's/process's time slice).
  • slicer69slicer69 Member Posts: 272
    The time delay can depend on the operating system you
    are using. If this program is for Linux/UNIX you can
    use the sleep() function.
    Under Windows 32-bit programming, it is called Sleep()
    (note the upper case "S").

    Another way that should work on any system, is to
    get the current time using the time() function.
    Then translate the time to struct with localtime().
    You can then get the current number of seconds.
    Do this contiually until the seconds value of the time
    struct has changed three times.
    Crude, but it works.


    : [b][red]This message was edited by Strobe at 2002-7-30 15:47:34[/red][/b][hr]
    : How does one implement a simple 3 second time delay? I've looked in alot of places on the web and one that seemed the easiest to use would be the supposed sleep() function of time.h But according to the compiler I'm using (Visual C++ 6.0) this function does not exist. Any help you could offer?
    :
    :

  • Andre YoungAndre Young USAMember Posts: 0

    _________ ( http://forcoder.org ) free ebooks and video tutorials about [ PL/SQL, Delphi, MATLAB, Go, Objective-C, C++, Visual Basic, Scratch, Visual Basic .NET, Swift, Assembly, C, Perl, PHP, C#, R, Python, JavaScript, Ruby, Java D, LabVIEW, Dart, Erlang, Bash, Crystal, Kotlin, Scala, COBOL, FoxPro, Rust, Ada, Alice, SAS, ML, Lua, Julia, ABAP, Transact-SQL, Scheme, Prolog, Fortran, Apex, Lisp, VBScript, F#, Logo, Hack, Awk, Clojure ] ____________

Sign In or Register to comment.