Listing 13: ctime.c
/* ctime.c */
/*
* print the UNIX time (day month time year) for the
* specified time. See also yearago.sh
*/
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
main(argc, argv)
int argc;
char *argv[];
{
int i;
time_t x;
if ( argc < 2 ) {
fprintf(stderr, "Usage: ctime [numbers]\n");
exit(1);
}
for ( i=1; i < argc; i++) {
x=(time_t)atol(argv[i]);
printf("%s", ctime(&x));
}
exit(0);
}
/* End of File */
|