#1
  1. No Profile Picture
    The Bisifiniti
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Posts
    25
    Rep Power
    0

    Causing a delay in milliseconds


    How do I cause the program to stop running for X amount of milliseconds?

    Example,

    for(i=1;1<10;i++){
    printf("%i\n",i);
    function_causes_100ms_wait;
    }

    Basically, I need a function that can pause the program. Couldn't find anything on Google or any books I have lying around.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    USA
    Posts
    286
    Rep Power
    13
    What platform are you programming on? I know that Sleep(...) works on Windows platforms.

    I'm sure there is a similar function for Unix, but I don't know what headers (if any) you would need to include.
    Jon Sagara

    "Me fail English? That's unpossible!"
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    Sweden
    Posts
    0
    Rep Power
    0
    If you are using unix, the function you're looking for is usleep, from unistd.h
    usleep suspends execution for X microseconds.

    Code:
    for(i=1;1<10;i++){ 
        printf("%i\n",i); 
        usleep(100000);
    }

IMN logo majestic logo threadwatch logo seochat tools logo