Results 1 to 5 of 5

Thread: Delay in execution of C program?

  1. #1
    Join Date
    Apr 2009
    Posts
    79

    Delay in execution of C program?

    I want to write program for implementing long time (200ms) delay in execution of loop in C language, can you give some good advice? Is that any syntax to put put a delay of milliseconds or seconds at any step in a C program.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Delay in execution of C program?

    Creating a software loop to generate time delays in C for each loop which delay the execution. You could try something like :
    Code:
    for (i=0;i<35;i++) 
    { 
    j=i; 
    }

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Delay in execution of C program?

    You probably want to use usleep(microseconds) : > #include <windows.h> and use > Sleep(ms). *note the capital S*. In C Programming both Sleep(), sleep(), and SleepEx() all pause for milliseconds.

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Delay in execution of C program?

    Delay for 10 seconds example
    Code:
    #include <stdio.h>
    #include <time.h> 
    int main()
    {
    time_t start;
    time_t current;
    
    time(&start);
    printf("delay for 10 seconds.\n");
    do{
    time(&current);
    }while(difftime(current,start) < 10.0);
    printf("Finished delay.\n");
    
    
    return 0;
    }

  5. #5
    Join Date
    Sep 2009
    Posts
    3

    Re: Delay in execution of C program?


Similar Threads

  1. WMI execution is different in windows 7
    By $Lola$ in forum Operating Systems
    Replies: 4
    Last Post: 22-02-2011, 08:42 PM
  2. Replies: 4
    Last Post: 29-12-2010, 06:49 AM
  3. Execution of program can not find the file
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 13-01-2010, 11:42 AM
  4. need help making time delay start for program
    By Brandon 2010 in forum Software Development
    Replies: 3
    Last Post: 22-06-2009, 08:08 AM
  5. Why C, C++ program execution starts with main()
    By RadhaV in forum Software Development
    Replies: 4
    Last Post: 13-02-2009, 08:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,016,964.56788 seconds with 16 queries