Piyush
Piyush

Reputation: 5325

How can i print %d in c

I want to print like %d in C but it's showing some number.

Upvotes: 1

Views: 11756

Answers (2)

codaddict
codaddict

Reputation: 455440

To get a % you need to have %%.

printf("%%d");

prints

%d

The printf man page says:

conversion   
specifier

   %         A '%' is written.  No argument is converted.  The complete  con‐
             version specification is '%%'.

Upvotes: 1

Fred Foo
Fred Foo

Reputation: 363838

printf("%%d"), or just fputs("%d", stdout).

Upvotes: 9

Related Questions