delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/08/26/14:06:47

Lines: 43
X-Admin: news AT aol DOT com
From: mmarkhinchcliffe AT aol DOT com (MMarkHinchcliffe)
Newsgroups: comp.os.msdos.djgpp
Date: 26 Aug 2003 17:48:59 GMT
Organization: AOL, http://www.aol.co.uk
Subject: Resetting IOS Flags
Message-ID: <20030826134859.28568.00000444@mb-m18.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I'd be very grateful if anyone could tell me what's wrong with the
following code.

The line "os.setf( oldflags, ios::basefield);"
gives 2 compilation errors:
"invalid conversion from 'long int' to 'std::_Ios_Fmtflags'"
&
"initializing argument 1 of 'std::_Ios_Fmtflags
std::ios_base::setf(std::_Ios_Fmtflags,std::_Ios_Fmtflags)"

/*
 * friend output operator
 * Parameters:
 *   os   - output stream to write to
 *   bigi - Big_int to print value of
 * Return value:
 *   reference to os
 */
ostream & operator << ( ostream &os,
                        const Big_int & bigi )
{
  long oldflags = os.setf( ios::hex, ios::basefield);

  char old_fill = os.fill('0');
  bool leading_zero = true;

  for( int i = bigi.size_ - 1; i >= 0; i-- ) {
    if ( ! leading_zero )
      os.width(8);
    if ( bigi.number_[i] != 0)
      leading_zero = false;
    else if (i != 0 && leading_zero)
      continue;
    os << bigi.number_[i];
  }

  os.fill(old_fill);
  os.setf( oldflags, ios::basefield);

  return os;
}

	Mark Hinchcliffe

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019