Solved

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

Posted on 2004-09-17
10
230 Views
Last Modified: 2010-04-15
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
Comment
Question by:Stephen Kairys
  • 5
  • 4
10 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
 
LVL 4

Author Comment

by:Stephen Kairys
Comment Utility
Is it the same as %u? If not, what is the difference? Thanks.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 50 total points
Comment Utility
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
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 50 total points
Comment Utility
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
 
LVL 4

Author Comment

by:Stephen Kairys
Comment Utility
Cool. That  clarifies it. Thanks so much :)
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 4

Author Comment

by:Stephen Kairys
Comment Utility
One more thing: I split your points since your last two posts both contained helpful info. Thanks again!
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
 
LVL 4

Author Comment

by:Stephen Kairys
Comment Utility
Valid point. Guess I wasn't thinking. I'll post on Community Support for a grade change.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
Thank you man, I preciate it. See you in next question.
Jaime.
0
 

Expert Comment

by:RomMod
Comment Utility
The grade has been changed to A as requested.

RomMod
Community Support Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now