[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

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
0
Stephen Kairys
Asked:
Stephen Kairys
  • 5
  • 4
2 Solutions
 
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
 
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
The Lifecycle Approach to Managing Security Policy

Managing application connectivity and security policies can be achieved more effectively when following a framework that automates repeatable processes and ensures that the right activities are performed in the right order.

 
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

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now