delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/08/15:50:24

Date: Wed, 8 May 1996 15:29:15 -0400 (EDT)
From: Justin Ward <justin AT yoss DOT canweb DOT net>
To: Rainer Wank <wank AT uebemc DOT siemens DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: vararg
In-Reply-To: <9605080624.AA16965@malta>
Message-ID: <Pine.BSF.3.91.960508152447.8229B-100000@yoss.canweb.net>
MIME-Version: 1.0


On Wed, 8 May 1996, Rainer Wank wrote:

> void abc(int anzahl, unsigned char abc, ...)
> {
>  va_list ap;
>  va_start(ap, abc);
>  fg = va_arg(ap, unsigned char);
>  printf("\n\rErster variabler Parameter: %d", fg);
>  va_end(ap);
> }

You are taking fg as a char, but printing it as an int. With djgpp, and 
int is 4 bytes and a char is either two or one (I think), depending on 
whether you're compiling as C or C++. On the sun and on bc 3.1, a char 
and an int are both 2 bytes it seems. I can't say for sure regarding the 
sun, but I know this is the case regarding bc. Anyway, just rewrite your 
printf using %c instead of %d and everything will be fine.

Justin

- Raw text -


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