delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/23/06:16:39

From: "Gerhard W. Gruber" <g DOT gruber AT sis DOT co DOT at>
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with streamclass
Date: Wed, 23 Sep 1998 11:56:28 +0200
Organization: S.I.S. IT
Lines: 35
Message-ID: <3608C5CC.505BD8D4@sis.co.at>
NNTP-Posting-Host: 192.56.14.75
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have a project that compiles fine with gcc 2.7.2.1 but when I try to
compile it with gcc 2.8.1 then I get an error with the following statement:

String CurrentDate( int diffDay = 0 )
{
  time_t t;
  time(&t);
  t += diffDay * 3600 * 24;
  struct tm atm = *localtime( &t );

  return SisStr() && ostrstream() << setfill('0')
			          << setw(4) << atm.tm_year+1900 
                                  << setw(2) << atm.tm_mon + 1
                                  << setw(2) << atm.tm_mday;
}

I get the following errormessage:
In function 'class String CurrentDate(int = 0)':
no match for 'ostrstram << smanip<int>'
candidates are : ostream::operator <<(...)

with a list of operators of all possible datatypes.

I tried this line with "cout << ..." and this works, so I wonder why it
doesn't work with ostrstram as well. Any ideas? I never used the
streamclasses before and I'm at a loss now.
-- 
Bye,
   Gerhard

email: sparhawk AT eunet DOT at
       g DOT gruber AT sis DOT co DOT at

Harrison's postulate:  
For every action, there is an equal and opposite criticism.

- Raw text -


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