What is the difference between %d and %i in printf and scanf in C?

Asked

Viewed 619 times

2

What is the difference between %d and %i no printf and in the scanf, in the C language?

1 answer

3

  • Are interpreted equally in printf, choose whichever you prefer.
  • In the scanf is that things are different.

The %d only recognizes numbers of base 10

The %i accepted octal (prefix 0) and hexadecimal (prefix 0x)

250 -> decimal

0250 -> octal

0x250 -> hexadecimal

Browser other questions tagged

You are not signed in. Login or sign up in order to post.