# include # include # include # include "counter.h" int main ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: counter_test() tests counter(). Licensing: This code is distributed under the MIT license. Modified: 12 May 2021 Author: John Burkardt */ { int i; timestamp ( ); printf ( "\n" ); printf ( "counter_test():\n" ); printf ( " C version\n" ); printf ( " Test counter(), with the interface:\n" ); printf ( " counter()\n" ); printf ( "\n" ); for ( i = 1; i <= 10; i++ ) { counter ( ); } /* Terminate. */ printf ( "\n" ); printf ( "counter_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: timestamp() prints the current YMDHMS date as a time stamp. Example: 17 June 2014 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 01 May 2021 Author: John Burkardt */ { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); printf ( "%s\n", time_buffer ); return; # undef TIME_SIZE }