# include # include # include # include # include "triangle_nodefile_random.h" int main ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: triangle_nodefile_random_test() tests triangle_nodefile_random(). Licensing: This code is distributed under the MIT license. Modified: 15 August 2024 Author: John Burkardt */ { char filename[] = "nodes.txt"; int m; int n; double *x; timestamp ( ); printf ( "\n" ); printf ( "triangle_nodefile_random_test():\n" ); printf ( " C version\n" ); printf ( " Test triangle_nodefile_random().\n" ); /* Create 20 random nodes in 2D. */ m = 2; n = 20; x = triangle_node_random ( m, n ); printf ( "\n" ); printf ( " Spatial dimension m = %d\n", m ); printf ( " Number of points n = %d\n", n ); /* Store this data in a triangle() node file. */ triangle_node_write ( filename, m, n, x ); printf ( "\n" ); printf ( " Data was written to the triangle node file '%s'\n", filename ); /* Free memory. */ free ( x ); /* Terminate. */ printf ( "\n" ); printf ( "triangle_nodefile_random_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 }