• C

Is there such a thing as an %i format specifier in C?

Hello.
Someone E-mailed me some information about C format specifiers, and in it, referreed to the
%hd and %hi format specifiers (the "h" specifing a short 16-bit int).

%hd makes sense to me as a "cousin" of %d, but "%hi" does not, since I'm not sure that there
is such a thing as %i. %hu (for unsigned) would seem more logical.  I've programmed in C for
about four years and have always used %d and %u.

Please advise.
Thanks
stevefromc
LVL 4
Stephen KairysTechnical Writer - ConsultantAsked:
Who is Participating?
 
Jaime OlivaresSoftware ArchitectCommented:
Forgot to mention: %d and %i are the same, just a matter of preferences.
Some references in the Internet:
http://web.cs.ualberta.ca/~pengzhao/book/chap03.html
http://staff.aes.rmit.edu.au/olga/programming1/html/c4.html
0
 
Jaime OlivaresSoftware ArchitectCommented:
I use to use %i specifier most of the time, it refers to a unsigned integer, and yes, it is a standard C specifier.
0
 
Stephen KairysTechnical Writer - ConsultantAuthor Commented:
Is it the same as %u? If not, what is the difference? Thanks.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
Jaime OlivaresSoftware ArchitectCommented:
About your last question: it is not the same as %u.
%i refers to a **signed** integer, while %u refers to an **unsigned** integer.
0
 
Stephen KairysTechnical Writer - ConsultantAuthor Commented:
Cool. That  clarifies it. Thanks so much :)
0
 
Stephen KairysTechnical Writer - ConsultantAuthor Commented:
One more thing: I split your points since your last two posts both contained helpful info. Thanks again!
0
 
Jaime OlivaresSoftware ArchitectCommented:
If both answers are totally clear, why the B grade?
B grade is suggested for semi-satisfactory answers.
I think I have fully answered your question, including theory links.
0
 
Stephen KairysTechnical Writer - ConsultantAuthor Commented:
Valid point. Guess I wasn't thinking. I'll post on Community Support for a grade change.
0
 
Jaime OlivaresSoftware ArchitectCommented:
Thank you man, I preciate it. See you in next question.
Jaime.
0
 
RomModCommented:
The grade has been changed to A as requested.

RomMod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.