Solved

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

Posted on 2004-09-17
10
251 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
posix semaphore deadlock 13 123
Inorder binary search tree 5 163
negation in C function 14 153
Console based application in Linux 1 89
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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

776 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