==== #include #include using namespace std; class TokenStream : public ifstream { public : TokenStream (string fileName) : ifstream (fileName) { nextChar (); nextToken (); } private: char ch; void nextChar (); public: string token; void nextToken (); }; const char eos = 0; void TokenStream::nextChar() { *this >> ch; if (! *this) ch = eos; } void TokenStream::nextToken () { while (ch != eos && ch <= ' ') nextChar (); token = ""; if (ch != eos) { if (ch >= 'a' && ch <= 'z') { while (ch >= 'a' && ch <= 'z') { token = token + ch; nextChar (); } } else { token = string (1, ch); nextChar (); } } } int main() { TokenStream f ("../stream/abc.txt"); // TokenStream f ("C:/Users/ZC/Documents/untitled4/abc.txt"); // TokenStream f ("../untitled4/abc.txt"); while (f.token != "") { cout << f.token << endl; f.nextToken (); } return 0; } // selmy ( psoviti, medvedoviti ) ; ====