/*
stopwatch.c

A simple stopwatch program which measures
the number of seconds between two Enter keys.

This is a simple demonstration of the time()
function and the difftime() function.

Ray Ontko, 1999/11/30
*/

#include <stdio.h>
#include <time.h>

int main()
{
  time_t start_time ;
  time_t stop_time ;
  int elapsed ;
  int c;

  printf( "Type the Enter key to START timing.\n" ) ;
  while( ( c = getchar() ) != '\n' && c != EOF ) 
    ;
  start_time = time( NULL ) ;

  printf( "Type the Enter key to STOP timing.\n" ) ;
  while( ( c = getchar() ) != '\n' && c != EOF ) 
    ;
  stop_time = time( NULL ) ;

  elapsed = difftime( stop_time , start_time ) ;
  printf( "Elapsed time: %d seconds.\n" , elapsed ) ;

  return 0;
}
