Solved

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

Posted on 2004-09-17
10
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

717 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