First, %D
isn't a standard.
When it comes to %d
and %i
, there's no difference for output (e.g: printf
), as pointed by some users on the comments and Oliver Charlesworth on his answer.
However, for input data (e.g.: scanf
) you can use %i
for scanning hexadecimal values (if preceded by 0x), or octal (if preceded by 0). Its default behavior will scan decimal values.
E.g: if you input some data using %i
like 0x28
, it will be the same as 40
in dec.
EDIT: Some code as example:
#include <stdio.h>
int main(){
int dec, hex;
scanf("%i",&hex); //For example, hex = 0x28
scanf("%d",&dec); //For example, dec = 28
printf("Hex: %d\nDec: %d\n",hex,dec); // outputs: Hex = 40, Dec = 28
}