Cover V02, I02
Article
Figure 1
Figure 10
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Listing 1
Listing 2
Listing 3
Listing 4
Table 1
Table 2
Table 3
Table 4

mar93.tar


Listing 2: gtimes.c

NAME

gtimes.c - Calculate clock times.

SYNOPSIS

gtimes [ clock value ]
- where clock value is a long integer which was previously returned
by the time system call.

DESCRIPTION

This program without an argument will report the current system time
both as an ASCII string, and as a long integer which is directly
reported from time(S).
Invocation with an argument results in the ASCII time string which
matches the clock value on the command line.

RETURN VALUE

Always returns 0.

WARNINGS

There are no provisions for bad data, or overflow.

-------------------------------------------------------------------------

*/
/* Copyright 1988 Chris Hare */

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <errno.h>

main( argc, argv )
int argc;
char *argv[];

{

char *ctime(),               /* declare ctime(S) */
*timestr;               /* storage area for
time string */
long int t_secs,             /* return value from time(S) */
o_secs,             /* long integer value of command argument */
atol(),             /* declare atol(S) */
time();             /* declare time(S) */
struct tm *mytime;
struct tm *localtime();
char *atime_str;

if ( argc == 1 )
t_secs = time(0L);
else
t_secs = atol(argv[1]);

timestr = ctime(&t_secs);

printf( "Clock : %ld\nDate  : %s\n", t_secs, timestr );

exit(0);

}