Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-230

arithmetic extractors affect gcount()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.1.2, 4.1.3
    • 4.2.0
    • 27. Input/Output
    • None
    • all

    Description

      Moved from the Rogue Wave bug tracking database:

      ***Created By: pedretti @ Apr 18, 2001 03:51:32 PM***
      basic_istream<>::gcount() is not ignoring characters consumed in formatted extraction operations.

      [ example program: ]

      #include <sstream>
      #include <iostream>

      using namespace std;

      int main () {

      stringstream ss;
      string s;
      int i;
      char c;

      ss << "12345 5678 hello world" << ends;
      cout << "gcount() before extraction : " << ss.gcount() << endl;

      ss >> i;
      cout << "gcount() after formatted extraction of int: "
      << ss.gcount() << endl;

      ss >> i;
      cout << "gcount() after 2nd formatted extraction of int: "
      << ss.gcount() << endl;

      ss >> s;
      cout << "gcount() after formatted extraction of string: " << ss.gcount() << endl;

      while (ss)

      { ss >> c; cout << "gcount() after formatted extraction of char: " << ss.gcount() << endl; }

      }

      [output:]

      gcount() before extraction : 0
      gcount() after formatted extraction of int: 0
      gcount() after 2nd formatted extraction of int: 1
      gcount() after formatted extraction of string: 1
      gcount() after formatted extraction of char: 2
      gcount() after formatted extraction of char: 1
      gcount() after formatted extraction of char: 1
      gcount() after formatted extraction of char: 1
      gcount() after formatted extraction of char: 1
      gcount() after formatted extraction of char: 1
      gcount() after formatted extraction of char: 0

      Attachments

        Issue Links

          Activity

            People

              sebor Martin Sebor
              sebor Martin Sebor
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: