csci4061/p1-code/sleep_print.c

23 lines
346 B
C
Raw Permalink Normal View History

2018-01-29 23:28:37 +00:00
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
// usage: sleep_print secs message
int main(int argc, char *argv[]){
int secs = atoi(argv[1]);
struct timespec tm = {
.tv_nsec = 0,
.tv_sec = secs,
};
nanosleep(&tm,NULL);
for(int i=2; i<argc; i++){
printf("%s ",argv[i]);
}
printf("\n");
return secs;
}