delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/01/27/09:46:54

Date: Thu, 27 Jan 1994 09:13:06 -0500 (EST)
From: Edwin L Phillips Jr <flaregun AT strauss DOT udel DOT edu>
Subject: Re: form syntax ... (fwd)
To: Hassan Saleh <salehh AT CSOS DOT ORST DOT EDU>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

On Wed, 26 Jan 1994, Hassan Saleh wrote:

> ---------- Forwarded message ----------
> Date: Thu, 20 Jan 1994 18:17:34 -0800 (PST)
> From: Hassan Saleh <salehh AT CSOS DOT ORST DOT EDU>
> To: djgpp AT sun DOT soe DOT clarkson DOT edu
> Subject: form syntax ...
> 
> Please can someone point out to me what is wrong with the following 
> program segment ? It won't compile with djgpp.
> 
> 
> ==========================================================
> #include "iostream.h"
> #include "string.h"
> 
> main()
> {
> int index;
> float distance;
> 
>    index = -23;
>    distance = 12.345;
> 
>    cout << "The value of distance is " << form("%12.4f\n",distance);
>    cout << form("Hello world!") << "\n";

   This may be the ^^^^^^^^^^^^^ problem.  In iostream.h, form is 
prototyped as:

	ostream& form(const char *format ...);

which may mean form should require at least 2 args.  Does anyone have the 
spec on this?  I'm used to seeing things like form(char *f, ...) instead 
of form(char *f ...).  It seems like it should be ok as written, but...
Also, what is the output of the compiler.  Where is it balking?

> 
>    cout << "Input a decimal value --> ";
>    cin  >> index;
>    cout << "The hex value of the input is " << index << "\n";
> }
> 
> 
> 
> 
> 
> 

	Ed

/***************************************************************************/
/* Ed Phillips  flaregun AT brahms DOT udel DOT edu       University of Delaware      */
/* Jr Systems Programmer  (302) 831-6082       NSS/Software Systems        */
/***************************************************************************/


- Raw text -


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