mrayoub:
%i and %d are equivalent. both of them specify the format for a signed decimal integer, and either are acceptable to use.
%u, as you have seen, is for unsigned decimal integer
however, if you have declared a variable of type int then you should not print it as %u, an unsigned int. That is a bad practice to get into... because while it may in many cases appear to work correctly, your integer may very well have a valid negative value , and the %u format will print an incorrect value.
if you want the variable to be unsigned, then make it unsigned by declaring it so: unsigned number;
.
Last edited by jephthah; Jun 27th, 2009 at 8:57 pm.
Reputation Points: 2143
Solved Threads: 178
Posting Maven
Offline 2,567 posts
since Feb 2008