bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rdstate(), istrstream, int, float


From: Alex Vinokur
Subject: rdstate(), istrstream, int, float
Date: Wed, 16 May 2001 07:31:55 +0200

==============================
%uname -sr
Linux 2.2.17-21mdk

%g++ -v
gcc version 2.95.3 19991030 (prerelease)
==============================

Here is a program.
A question is below.

---------- C++ code : BEGIN --------------

#include <string>
#include <iostream>
#include <strstream>

//======================================
int main ()
{
string          s1(" ");
istrstream      tmp1(s1.c_str());
istrstream      tmp2(s1.c_str());

int             the_int;
float           the_float;

        tmp1.unsetf(ios::skipws);
        tmp1 >> the_int;
        cout << "int\t : rdstate() = "
                << tmp1.rdstate ()
                << ", in_avail() = "
                << tmp1.rdbuf()->in_avail()
                << endl;

        tmp2.unsetf(ios::skipws);
        tmp2 >> the_float;
        cout << "float\t : rdstate() = "
                << tmp2.rdstate ()
                << ", in_avail() = "
                << tmp2.rdbuf()->in_avail()
                << endl;

        tmp1.rdbuf()->freeze (0);
        tmp2.rdbuf()->freeze (0);

        return 0;
}


---------- C++ code : END ----------------


---------- Running : BEGIN ---------------

%a.out

int      : rdstate() = 3, in_avail() = 0
float    : rdstate() = 1, in_avail() = 0

---------- Running : END -----------------

We can see that rdsate() values are different for 'int' and 'float'
(while using noskipws).
What difference between 'int' and 'float' causes that.

==================================
Alex Vinokur
   mailto:address@hidden
   http://up.to/alexvn
   http://visitweb.com/alexvn.math
==================================






reply via email to

[Prev in Thread] Current Thread [Next in Thread]