home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch8 / position.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  1KB  |  50 lines

  1. /*                      position.c
  2.  *
  3.  *   Synopsis  - Program calls endofsen() to read input up to 
  4.  *               the first occurrence of '.', '?', or '!' and 
  5.  *               then calls a stub function (that needs to be 
  6.  *               completed) to process the remaining input.
  7.  *
  8.  *   Objective - To illustrate calling of a function for the 
  9.  *               tasks it performs and not for its return value
  10.  *               or its parameter value.
  11.  */
  12.  
  13. /* Include Files */
  14. #include <stdio.h>
  15.  
  16. /* Function Prototypes */
  17. extern int endofsen( int *punctptr );
  18. /* See Example 8-12 for precondition and postcondition information.
  19.  */
  20.  
  21. void processinput( void );
  22. /* PRECONDITION:  none.
  23.  *
  24.  * POSTCONDITION: A stub function. It reads to end of input. 
  25.  */
  26.  
  27. int main( void )
  28. {
  29.      int dummy;
  30.  
  31.      printf( "Enter your input now.  Terminate by " );
  32.      printf( "signaling end of file.\n" );
  33.  
  34.      endofsen( &dummy );                             /* Note 1 */
  35.  
  36.      processinput();
  37.      return 0;
  38. }
  39.  
  40. /*******************************processinput()******************/
  41.  
  42. void processinput( void )
  43. {
  44.      int iochar;
  45.  
  46.      while (( iochar = getchar() ) != EOF ) {       /* Note 2 */
  47.           /* code for processing would go here */
  48.      }
  49. }
  50.