[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Not an xwpe question.
This is take II of this message. I think Dennis's mail program did some
processing on it when it redistributed it.
At 01:40 PM 5/30/00 -0600, Roy Souther wrote:
>I am having a problem with, I think, my compiler and I just wanted to know if
Nope, I believe you actually are using printf incorrectly.
>anyone eles is having a similar problem. I am using egcs 2.91.66 on Red
>My problme is unsigned ints and unsigned longs, they are singend. I have been
>having problems with my software and wrote this code to find that problem.
This should be int main (void), but it doesn't really matter. Some
compilers will complain about this. This of course has nothing to do with
your problem, but as a former CS I instructor, I have to point it out. :)
> printf("sizeof(MyUInt)=%d\n",sizeof(MyUInt)); // Shows
> 4, good
MyUInt has the value you want it to have.
Nope, it's right. %d is for signed integers. You are getting an implicit
conversion here, so it is as if you wrote:
printf("MyUInt=%d\n\n", (signed int) MyUInt);
Instead, you need to use:
where %u is the format specifier for unsigned decimal. I'm not sure this
is the only bug in your code (I don't have time right now to compile and
test it), but it is the obvious bug.