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 / endofsen.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  977b  |  28 lines

  1. /*                          endofsen.c
  2.  *
  3.  * int endofsen( int * punctptr )
  4.  * PRECONDITION:  punctptr contains the ASCII value of a character 
  5.  *                variable that will contain a found puctuation 
  6.  *                mark.
  7.  *
  8.  * POSTCONDITION: A function that finds the end of a sentence if
  9.  *                it ends in '.', '?', '!'.  Returns 1 for
  10.  *                success, 0 for end-of-file. 
  11.  *
  12.  */
  13.  
  14. /* Include Files */
  15. #include <stdio.h>
  16.  
  17. int endofsen( int * punctptr )                                  /* Note 1 */
  18. {
  19.      int iochar;
  20.      while ( ( iochar = getchar() ) != EOF )
  21.           if (( iochar == '.' ) || ( iochar == '?' )
  22.                                 || ( iochar == '!' )) {
  23.                *punctptr = iochar;                              /* Note 2 */
  24.                return 1;                                        /* Note 3 */
  25.           }
  26.      return 0;                                                  /* Note 4 */
  27. }
  28.