ppc_fetch_line_test(): C version. Test ppc_fetch_line(). 6: int main ( ); 7: void timestamp ( ); 9: /******************************************************************************/ 11: int main ( ) 13: /******************************************************************************/ 14: /* 15: Purpose: 17: ppc_fgets_demo() shows how fgets() reads character data into a buffer. 19: Licensing: 21: This code is distributed under the GNU LGPL license. 23: Modified: 25: 05 September 2023 27: Author: 29: John Burkardt 31: Reference: 33: Rouben Rostamian, 34: Programming Projects in C 35: for Students of Engineering, Science, and Mathematics, 36: SIAM, 2014, 37: ISBN: 978-1-611973-49-5 38: */ 39: { 40: char buf[BUFLEN]; 42: timestamp ( ); 43: printf ( "\n" ); 44: printf ( "ppc_fgets_demo():\n" ); 45: printf ( " C version\n" ); 46: printf ( " Demonstrate how fgets() reads data from a buffer.\n" ); 47: printf ( "\n" ); 49: while ( fgets ( buf, BUFLEN, stdin ) != NULL ) 50: { 51: printf ( "%s", buf ); 52: } 53: /* 54: Terminate. 55: */ 56: printf ( "\n" ); 57: printf ( "ppc_fgets_demo():\n" ); 58: printf ( " Normal end of execution.\n" ); 59: timestamp ( ); 61: return 0; 62: } 63: /******************************************************************************/ 65: void timestamp ( ) 67: /******************************************************************************/ 68: /* 69: Purpose: 71: timestamp() prints the current YMDHMS date as a time stamp. 73: Example: 75: 17 June 2014 09:45:54 AM 77: Licensing: 79: This code is distributed under the GNU LGPL license. 81: Modified: 83: 01 May 2021 85: Author: 87: John Burkardt 88: */ 89: { 92: static char time_buffer[TIME_SIZE]; 93: const struct tm *tm; 94: time_t now; 96: now = time ( NULL ); 97: tm = localtime ( &now ); 99: strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); 101: printf ( "%s\n", time_buffer ); 103: return; 105: } ppc_fetch_line_test(): Normal end of execution. 07 September 2023 09:13:43 PM