View Single Post
  #3 (permalink)  
Old December 27th, 2006, 02:47 AM
C@uark C@uark is offline
Authorized User
 
Join Date: Oct 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to C@uark
Default

Extraction stops for the operator>> for a couple of resons one of which is:

After the function extracts an element ch for which use_facet<ctype<CharType> >( getloc). is( ctype<CharType>::space, ch) is true, in which case the character is put back.

If the function extracts no elements, it calls setstate(ios_base::failbit). In any case, it calls istr.width(0) and returns *this.

when using the cin operator>> to extract data, a newline character is being left in the buffer. so on its next consecutive read with the string class helper function getline(), the fail bit flag is being set and your string is set to an empty status. try suing the following

// use a cin.ignore() after extracting the continue option
    cin >> op;
    if ( cin.peek()=='\n' )
        cin.ignore();
Reply With Quote