csci4061/lab03-code/sleep_print.c
Michael Zhang 041f660ccd
f
2018-01-29 17:28:37 -06:00

24 lines
419 B
C

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
// usage: sleep_print secs message
//
// Sleep for the given number of seconds then print the given 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;
}