Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Examples  

word.C File Reference

#include "word.h"
#include <ctype.h>

Go to the source code of this file.

Functions

istream & operator>> (istream &is, Word &w)


Function Documentation

istream& operator>> istream &    is,
Word   w
 

Non-alhabetic characters before and after the word will be skipped.

Parameters:
is  stream to read from.
w  word that will be read (it is cleared beforehand).
Returns:
reference to is.

Definition at line 9 of file word.C.

References Word::w_.

00009                                  {
00010 w.w_.resize(0);
00011 char c(EOF);
00012 while (is.get(c) && ! isalpha(c))
00013   ;
00014 if ( isalpha(c) ) {
00015   do 
00016     w.w_ += tolower(c);
00017   while (is.get(c) && isalpha(c));
00018   // operation succeeded, so we want stream in ok state
00019   // otherwise is >> w would fail if w was followed in is by EOF 
00020   is.clear();
00021   }
00022 return is;
00023 }


textindexer-0.2 [27 March, 2002]