All pastes #39687 Raw Edit

Unnamed

public text v1 · immutable
#39687 ·published 2006-02-02 22:57 UTC
rendered paste body
#include <unistd.h>  // for usleep
#include <stdio.h>   // for printf()
#include <stdlib.h>  // for atof()

/* compile with
gcc -g -Wall -o smallsleep smallsleep.c
*/

#define MICROSECONDS_IN_SECONDS 1000000

int main (int argc, const char *argv[])
{
    if (argc != 2) {
        fprintf (stderr, "usage: %s time-in-seconds\n", argv[0]);
        fprintf (stderr, "   (decimal values are OK for the time\n");
        return (1);
    }

    float fraction;
    fraction = atof (argv[1]);

    usleep (fraction * MICROSECONDS_IN_SECONDS);

    return (0);

} // main