For printf, they are exactly the same.
http://en.cppreference.com/w/cpp/io/c/fprintf
d
, i
converts a signed integer into decimal representation [-]dddd.
Precision specifies the minimum number of digits to appear. The default precision is 1.
If both the converted value and the precision are 0 the conversion results in no characters.
For scanf, they are different. Below is quote from documentation.
d
matches a decimal integer.
The format of the number is the same as expected by strtol() with the value 10 for the base argument
i
matches an integer.
The format of the number is the same as expected by strtol() with the value 0 for the base argument (base is determined by the first characters parsed)
In case of i
, if your number starts with 0
, it will be parsed as octal.
http://en.cppreference.com/w/cpp/io/c/fscanf