locked
Is there any functions in c language to halt execution of code at run time?????????? RRS feed

  • Question

  • Is there any functions in c language to halt execution of code at run time??????????




    I am working out a program that should execute code with an interval between each statement of program .

    How can i do it .....Is there any predefined function............in c language


    Thursday, February 15, 2007 2:10 PM

All replies

  • use delay function. or also you can go for busy polling

     

    hope this works

    Thursday, February 15, 2007 5:55 PM
  • ya its better to use the delay function...but i really don understand ur question fully...do u jus want to introduce delay or u want delay between each and every statement in the program...?
    Friday, February 16, 2007 12:05 AM
  • Well there is no exact function which you include just once in your program and it will automatically put delay in eaach statement. If you are working on kind of debugger which halts  after execution of each statement then you need to control interrupts yourself.

    In other case , just use code like below which is an adhoc solution but specialized version may be found for your compiler

    void delay(int milliseconds)

    {

     for (int x=0;x<milliseconds;x++);

    }

    or there is a delay like functon in stdlib in some versions.

    Just post back if you still have doubt.

    Friday, February 16, 2007 4:03 AM
  • thats what i meant by busy polling  shirish
    Friday, February 16, 2007 4:38 PM
  • Just telling about technical terms sometimes doesn't help.. so try to support your view point by some code examples..

    But i appreciate your work of helping people in their endeavours.

    Saturday, February 17, 2007 5:04 AM
  • You can try using delay function.. i think that is the best option.
    Saturday, February 17, 2007 7:16 AM
  • You can use the delay function or some user defined function of ur own using the existing delay function in order to fix the time limit as per u need. Other than that C Programming both Sleep() and SleepEx() cause a pause for milliseconds. 
    Saturday, February 17, 2007 2:06 PM
  • hey i used these before but it does seems to provide the expected delay in running>>>>>>>>.
    Wednesday, February 28, 2007 7:04 AM
  • no ...no ...thats no the function i am wanted ....But its a great thinking...........
    Wednesday, February 28, 2007 7:06 AM
  • dear friend if DELAY(time in millisec) is not the function u want then go for getch();

    definitely until u prass any key u wont move ahead

    for permanent halt just put getch() function in infinite loop.

    Wednesday, February 28, 2007 9:17 AM
  • run an infinite loop to halt execution temporarily at runtime.
    Wednesday, February 28, 2007 6:37 PM
  • yeah the best way is to run an infinite loop
    like while(1)
    {
    }
    Tuesday, March 6, 2007 3:00 PM
  • nope dude.
    it will never put your execution to halt.
    don't ever use infinite loop like the guy above me mentioned
    Saturday, May 26, 2007 1:32 AM
  • use sleep() or wait().
    they are far better.
    or if you are using turbo c++, then there itself you can do step execution.
    hope this might solve your problem.
    but never try to use infinite loop.
    because your execution is still not stopped. you are just making the CPU busy to do nothing
    Saturday, May 26, 2007 1:34 AM