home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch5 / testconv.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  894b  |  36 lines

  1. /*                 testconv.c
  2.  *
  3.  *   Synopsis  - Inputs lines with fgets() and passes 
  4.  *               the string to conv(). Displays the 
  5.  *               value returned by conv() and the 
  6.  *               remainder of the string.
  7.  *
  8.  *   Objective - To provide a test program for the 
  9.  *               user-written function to convert a 
  10.  *               string of digits to type int.
  11.  */
  12.  
  13. /* Include Files */
  14. #include <stdio.h>
  15. #include <string.h>
  16.  
  17. /* Constant Definitions */
  18. #define LGTH 80
  19.  
  20. /* Function Prototypes */
  21. int conv( char [], char ** );
  22. /* Fill in your PRECONDITION and POSTCONDITION here. */
  23.  
  24. int main( void )
  25. {
  26.      int intval;
  27.      char array[LGTH], *remainder;
  28.  
  29.      while ( fgets( array, LGTH, stdin ) != NULL ) {
  30.           intval = conv( array, &remainder );
  31.           printf( " %d, %s\n", intval, remainder );
  32.      }
  33.      return 0;
  34. }
  35.  
  36.