In message , Terje Sletteb� writes >I would be interested to know how read() is implemented. Could you >posted it? Well for what they are worth here is the complete set of overloaded function templates Comments for improving them are very welcome. // These templates provide safe input for any type that supports operator>> // 1) from console with prompt template in_type read(std::string const & prompt, int max_tries = 3){ in_type temp; int tries(0); while(tries++ != max_tries ){ std::cout << prompt; std::cin >> temp; if(std::cin.good()) return temp; std::cin.clear(); // if it has failed, reset it to normal while(cin.get() != '\n'); flush stream std::cout << "\n That input was incorrect, try again: \n"; } throw fgw::problem("Too many attempts to read data."); } // 2) version without prompt, defaults to colon space prompt template in_type read(int max_tries=3){ return read(": ", max_tries); } // 3) version for general input stream, throws an exception if fails template in_type read(std::istream & in){ in_type temp; in >> temp; if(in.good()) return temp; if(in.eof()) throw fgw::problem("Tried to read past end of file"); // handle end of file as special case in.clear(); // reset input stream throw fgw::problem("Corrupted data stream."); } -- ACCU Spring Conference 2003 April 2-5 The Conference you should not have missed ACCU Spring Conference 2004 Late April Francis Glassborow ACCU [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]