Listing 2: setutctime.c
/* setutctime.c
Sets the system clock from a specified UTC calendar time, using the
stime() function. */
#include <stdio.h>
#include <time.h>
void main (int argc, char *argv[] )
{
time_t user_supplied_time;
if ( argc != 2 )
{
fprintf( stderr, "Usage: setutctime calendar_time.\n" );
exit(1);
}
sscanf( argv[1], "%ld", &user_supplied_time );
if( stime( &user_supplied_time ) != 0 )
{
fprintf( stderr, "Unable to set time.\n");
exit(1);
}
exit(0);
}
/* End of File */
|