Thread: How to use delay() in another function?

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    54

    Post How to use delay() in another function?

    Im using C with header file dos.h where delay() function works correctly in main function but when I use delay() in another function and calls it, it corrupts whole program. the program refreshes continously. how I use delay() in another function?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > but when I use delay() in another function and calls it, it corrupts whole program.
    What does this mean?
    Post some code which shows the problem you're facing.

    But if your compiler is TurboC, and your OS is something like Windows XP or newer, then the only advice you need is to upgrade your compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    54
    bro Im using Turbo C++ 3.0 in windows xp

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by shansajid View Post
    Im using C with header file dos.h where delay() function works correctly in main function but when I use delay() in another function and calls it, it corrupts whole program. the program refreshes continously. how I use delay() in another function?
    Not withstanding the concern of your using an obsolete compiler, the delay() function shipped with Turbo C++ is not something that "corrupts whole program".

    There are two likely explanations. The first is that you have implemented a function named delay() which is doing something it shouldn't. The other possible explanation is that some other unrelated code in your program is doing something untoward, such as writing to an area of memory it shouldn't.

    Either way, without a small sample of representative code (i.e. code that compiles, links, and exhibits the unwanted symptoms when run) nobody can help you. If your program is large, do some work to create a small code sample that exhibits your problem.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. generic delay() function
    By moonlord in forum C Programming
    Replies: 8
    Last Post: 08-10-2005, 02:27 AM
  2. Is there a delay function?
    By Digga in forum Windows Programming
    Replies: 2
    Last Post: 05-06-2005, 10:56 AM
  3. Delay function
    By knight543 in forum C++ Programming
    Replies: 4
    Last Post: 01-14-2002, 03:04 PM
  4. Use a delay function
    By Robert_Ingleby in forum C++ Programming
    Replies: 2
    Last Post: 11-23-2001, 06:58 AM
  5. time delay function available?
    By cUser in forum C Programming
    Replies: 3
    Last Post: 10-01-2001, 12:14 AM