delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/12/18/02:30:26

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: PLEASE EXPLAIN v2.953
Date: Sat, 18 Dec 2004 02:15:57 -0500
Lines: 70
Message-ID: <32i3pjF3lsraeU1@individual.net>
References: <4tg7s0182f12t4dlbri2pdq2uqq6ausos7 AT 4ax DOT com>
Mime-Version: 1.0
X-Trace: individual.net CtXzVAlBZ6FJnaa5q+TclQvITyR146KwdTPlb5qevcs41vmhJG
User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103)
X-Accept-Language: en-us, en
In-Reply-To: <4tg7s0182f12t4dlbri2pdq2uqq6ausos7@4ax.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Radical NetSurfer wrote:
> I am using:
> 
> c:\djgpp>gcc --version 
> 2.953
> 
> EXPLAIN PLEASE the problem with THIS snippet:



#include <stdio.h>

int main(void)
{
     signed short ashort = -12345;
     unsigned short ushort = 65432;
     signed long along = -12345678;
     unsigned long ulong = 12345678;

     printf("(signed) Short: %hd\n", ashort);    /* mha; fixed.  'h' is
                                                    a flag, not a
                                                    complete specifier. */

     printf("Unsigned Short: %u\n\n", ushort);

     printf("[ 1] (signed) Short: %d\n", ashort);
     printf("[ 2] Unsigned Short: %u\n", ushort);
     printf("[ 3] (signed) Long: %ld\n", along); /* mha: fixed.  'D' is
                                                    not a specifier */
     printf("[ 4] Unsigned Long: %lu\n", ulong); /* mha: fixed.  'U' is
                                                    not a specifier */
     printf("[ 5] signed Long as unsigned hex: %#lX\n",
            (unsigned long) along);
   /* mha: eliminated warnings, if not fixed. X is for unsigned values
      only */
     printf("[ 6] (unsigned) Long: %#lX\n", ulong);  /* mha: fixed */
   /* mha: case [ 7] when 'fixed' is case 5. */
     printf("[ 8] (signed) Long: %#lX\n", ulong);
     printf("[ 9] (signed) Long: %ld\n", along);
     printf("[10] (signed) Long: %lu\n", ulong);

     return 0;
}

  /*
     OP: The point here is: When was %h dropped? and WHY?

     mha: It wasn't.  See above.

     OP: USING %lX with 2.953 seems to cause DJGPP to cause EXTRANEOUS
     GARBAGE to be output to the screen, and get this: from *OTHER*
     parts of the program !!!!

     mha: You just never bothered to read the beginner's information on
     using printf specifiers. */


(signed) Short: -12345
Unsigned Short: 65432

[ 1] (signed) Short: -12345
[ 2] Unsigned Short: 65432
[ 3] (signed) Long: -12345678
[ 4] Unsigned Long: 12345678
[ 5] signed Long as unsigned hex: 0XFF439EB2
[ 6] (unsigned) Long: 0XBC614E
[ 8] (signed) Long: 0XBC614E
[ 9] (signed) Long: -12345678
[10] (signed) Long: 12345678

- Raw text -


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