Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Functional Programming in C Conditionals - If-Else

Joe Voll
Joe Voll
304 Points

What are %c and %d?

I'm confused by %c and %d. Can we assign any letter to the % or does it have to be "c" and "d"? Do "c" and "d" signify something?

1 Answer

Dylan Shine
Dylan Shine
17,565 Points

The % Format Specifiers

The % specifiers that you can use in ANSI C are:

Usual variable type Display

%c char single character

%d (%i) int signed integer

%e (%E) float or double exponential format

%f float or double signed decimal

%g (%G) float or double use %f or %e as required

%o int unsigned octal value

%p pointer address stored in pointer

%s array of char sequence of characters

%u int unsigned decimal

%x (%X) int unsigned hex value