🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.misc
Article #2791

Re: Please help: Using args to obj func

#2791
From: dev
Date: Tue, 17 Oct 1995 17:16
50 lines
2103 bytes
Vladimir Alexiev (vladimir@cs.ualberta.ca) wrote:
: In article <45pr3o$43s@news.xmission.com> dev@xmission.com (dev) writes:
: 
: > I have created a class, with functions with multiple parameters.
: Perhaps you mean "variable number of parameters"?
No.
: 
: > But, if I try to use more than one in this call
: > i.i.  fprintf( fp, "1 is '%s' 2 is '%s' 3 is '%s'", p1, p2, p3 )
: > Then everything after the first param is junk.
: 

Here is some code:

class MyClass
{
public:
  // NOTE: Fixed number of params (not varargs)
  int MakeAString( char *fmt, char *str, int i, long l );
}
int
MyClass::MakeAString ( char *fmt, char *str, int i, long l );
{
  char tmpstr[200];

  sprintf( tmpstr, "%s", str ); // Works ok.
  sprintf( tmpstr, "%d", i   ); // Also works.
  sprintf( tmpstr, "%ld", l  ); // also works.
  sprintf( tmpstr, "%s %d", str, i );  // str shows up ok, %d shows bogus val
  sprintf( tmpstr, fmt, str, i );  // who knows.
  return(0);
}

So, it seems that anything after the first param (to a function using varargs)
is lost.

Also, I'm trying to use strftime( outstr, size, fmt, tm ) and the format
(which is a passed arg)  doesn't work.

: PS: Wrong group! Folloups redirected to comp.lang.c++

Actually, I posted here because I am using VC++ 1.50, and didn't want
the c++ forum booting me to here because I'm using that...
I thought it was probably a VC++ related problem.  It should be posted
to both.

dev
-- 
                "Expect the worst (you won't be disappointed)."
                      Brought to you by dev@xmission.com
Technical Details
Message-ID: <460oe9$5a9@news.xmission.com>
Path: arc1-ca.pugleaf.net!charnel.ecst.csuchico.edu!xmission!xmission!not-for-mail
References: <45pr3o$43s@news.xmission.com> <omzqf01pxk.fsf@tees.cs.ualberta.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!charnel.ecst.csuchico.edu!xmission!xmission!not-for-mail
From: dev@xmission.com (dev)
Newsgroups: comp.os.ms-windows.programmer.misc,comp.lang.c++
Subject: Re: Please help: Using args to obj func
Date: 17 Oct 1995 17:16:57 GMT
Organization: XMission Internet (801 539 0900)
Message-ID: <460oe9$5a9@news.xmission.com>
References: <45pr3o$43s@news.xmission.com> <omzqf01pxk.fsf@tees.cs.ualberta.ca>
NNTP-Posting-Host: xmission.xmission.com
X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]