Subj : istream& getline (istream& is, string& str, char delim = '\n'); To : borland.public.cpp.borlandcpp From : Maya Date : Tue Oct 28 2003 01:55 pm Question: Help using ' istream& getline (istream& is, string& str, char delim = '\n'); ' First of all, I apologize I am addressing this question to the wrong mail_list/news_group. If so, please just disregard this message. Here is my problem: The below overloaded extractor is not the only one in my class. There is an overloaded extractor for all the primitive data types as well as for std::string objects. All of inserters and extractors handling primitive data types are identical, the only difference is that each handles different data types. However, the overloaded operator handling std::string objects is giving me some strange behavior. Staring with the data in the file stream and continuing with a sip of the source code, let me show you what it is that I am talking about. -- data in the file stream is: -- Where are the weapons of mass destruction? Sir.^ -- snip -- virtual std::string& operator>>(std::string& data) throw(jme::CursorPosition, jme::StreamEx, std::bad_alloc){ /** Set the position of the file get pointer, if there are any errors throw an exception explaining what when wrong **/ try{setNextRead();} catch(jme::CursorPositionEx& x){throw; } catch(jme::StreamEx& x) {throw; } /** Make sure that there is data to be read in the file**/ if(file_is_empty()){ throw io_baseEx(FE_EMPTY,FILE,METHOD,LINE);} /** set the file's cursor position the the value returned by getNextRead(), which will never be < zero **/ f.seekg( getNextRead()); /** Get the a string from of character from the file stream until "^" is found **/ std::getline(f,data,'^') //Testing std::cout << "Data is: " << data << std::endl; <<== Displays the right string value std::cout << "Current Cursor Pos " << f.tellg() << std::endl; //<== Returns -1; an error?? std::cin.get(); //End testing try{setNextRead();} catch(jme::CursorPosition& x){ throw; } catch(jme::StreamEx& x){throw; } <== because ftellg is -1 this exception is thrown f.sync(); return data; } Again, thanks folks for the help! -- Jorge Escalante FYI http://www.astro.umd.edu/~marshall/abbrev.html E-Mail Policy http://www.vif.com/users/escalante/Email_Policy.html * You cannot exercise your power to a point of humiliation. - Jean Chretien * The media's the most powerful entity on earth. They have the power to make the innocent guilty and to make the guilty innocent, and that's power. - Malcom X * "Innocent until proven guilty", no... not in Canada!! .