Mail Archives: djgpp/2004/12/18/02:30:26
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 -