Possible Duplicate:
Difference between format specifiers %i and %d in printf
This question is motivated by the fact I use to see this preference in all the C code I've read.
Possible Duplicate:
Difference between format specifiers %i and %d in printf
This question is motivated by the fact I use to see this preference in all the C code I've read.
%d and %i
mean same in printf i.e. int;signed decimal notation but in scanf
%d is for decimal integer,int * and %i is for integer;int * the integer may be in octal(leading 0) or hexadecimal(leading 0x).
As far as I understand, %d implies base-10 (d is for DECImal), and i is base-flexible (you can use modifiers to indicate octal or hex). So, you should use d if you don't want to think about it, and you always want base-10
i and d conversion specifiers are equivalent for fprintf but they are different for fscanf.
Both i and d are present in all C standards (C89, C90, C11).
d is more common than i so I prefer to use d for fprintf.