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

Gnu C++ libs seems to be missing a few things



	I'm currently writing some code and I'm finding certain things are 
are not working correctly.  Some sample code:

#include <string>
#include <fstream>
//#include <iomanip> // for noskipws
int main( int argc, char* argv[] )
{
  ifstream ifile( argv[ 1 ] );
  if ( !ifile )
    {
      cerr << "Cannot open the file, " << argv[ 1 ] << " for reading.\n";
    } 
  string word;
  ifile.unsetf( ios::skipws ); // this should eliminate using whitespace as  
                               // a delimiter, it doesn't.  Why?
  //ifile >> noskipws >> word; // doesn't work, error says noskipws
	                       // undefined
  ifile >> word;
  cout << word << endl;
  return 0;
}

	The unsetf() function seems to do nothing at all. I'm getting the
first word of the file I'm reading from, rather than the whole file as a
long string.  noskipws also doesn't work, even with including <iomanip>.
The book, The C++ Programming Language, shows that these should work.
	Another sample of code:

#include<bitset>
#include<iostream>
#include<string>
using namespace std;
int main()
{
  unsigned int number_entered;
  cout << "Enter a number to be converted to binary." << endl;
  cin >> number_entered;
  bitset< 32 > binary_val( number_entered );
  string bitval( binary_val.to_string() );
  cout << "The value in binary is: " << bitval << endl;
  return 0;
}
	
	The to_string() function gives this error message when I try to
compile.

bitsets.C:15: no matching function for call to `bitset<32,long unsigned
int>::to_string ()'

	This function is able to be called on a bitset. The book, C++
Primer uses this.

	The version of glib++ and gcc are as follows:

Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011006 (Debian prerelease)
libstdc++2.10- 2.95.4-0.01100 The GNU stdc++ library
libstdc++2.9-g 2.91.66-4      The GNU stdc++ library (old egcs version)

	Am I hopelessly misguided or is this not my error?

Ian
-- 
FreeSoftware Developer
Registered GNU/Linux user 239985
and user of Debian GNU/Linux

Attachment: pgpyoC_t_3Y6q.pgp
Description: PGP signature


Reply to: