c

This is a discussion on c within the C Programming forums, part of the General Programming Boards category; what is command for time delay between two statements and also tell me the prototype...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    1

    Unhappy c

    what is command for time delay between two statements and also tell me the prototype

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Er... This isn't really a place to request things. But, I will tell you it's platform specific.

    Research Sleep() if on Windows, else sleep() if on Linux.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    11
    yeah....zacs7 is rite...if u r using some TurboC or some compiler which doesn't support this system call then u can simply loop up null statement for undefined interval of time...I mean, the time interval isn't known exactly...but there will be a delay...
    say some definition line
    Code:
    #define SOMENUMBER 1000000
    Code:
    <statement set 1>
    for(i=0;i<SOMENUMBER;i++);
    <statement set 2>
    but u cannot really specify the time correctly in this case....
    cheers

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    The problem with that though, you're unnecessarily raping the CPU. And the 'time' between statement 1 and statement 2 will vary upon the system load, not to mention other factors (caching and what have you).

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    11
    yeah... ....this is an overhead to CPU....it is doing nothing just eating away the cycles by noops ...i was just looking at DELAY...that's wat i was tellin...time interval cannot be specified in this case....

    cheers

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,424
    If you're forced to use a loop to delay, it's time to upgrade compiler.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21