Solved

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

Posted on 2004-09-17
10
261 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
ID: 12086203
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
ID: 12086219
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
ID: 12086226
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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 50 total points
ID: 12086241
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
ID: 12086255
Cool. That  clarifies it. Thanks so much :)
0
 
LVL 4

Author Comment

by:Stephen Kairys
ID: 12086271
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
ID: 12086310
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
ID: 12086325
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
ID: 12086417
Thank you man, I preciate it. See you in next question.
Jaime.
0
 

Expert Comment

by:RomMod
ID: 12086543
The grade has been changed to A as requested.

RomMod
Community Support Moderator
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

828 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