Mail Archives: djgpp/2003/07/28/12:10:55
> From: "News Reader" <nospam AT aol DOT com>
> Newsgroups: comp.os.msdos.djgpp
> Date: Mon, 28 Jul 2003 16:44:36 +0200
>
> According to my DJGPP documentation (C-library, HTML)
> the format string "%U" instead of "%lu" should work,
> but it doesn't.
How do you mean ``doesn't work''? What exactly did you expect and
what did you see (a short test program and sample output would be
nice)?
Here's my test program:
#include <stdio.h>
int main (int argc, char *argv[])
{
unsigned long k = argc * 3000000000LU;
printf ("num: %U %ld\n", k, k);
return 0;
}
and its output when invoked with no arguments (i.e. argc = 1):
num: 3000000000 -1294967296
As you see, printing with %U succeeds while %ld tries to interpret the
unsigned value as signed and overflows.
The only problem with %U that I see is that it is non-standard, so
"gcc -Wall" rightfully complains about it. But the program works
nonetheless.
- Raw text -