+ 1

Format specifier

In maximum conditions format specifier are know as the first element of data type. Like as: %f --> float %c --> char %s --> string ..And so on, but why an integer (int) specifier known as '%d', why it is not '%i' or any other character?? I want know only what is the meaning of "d", is "d" meaningful??? Please tell me🙂

20th Sep 2020, 7:20 PM
Rupali Haldiya
Rupali Haldiya - avatar
4 Antworten
+ 5
%d for decimal that means that the number should be base 10 number you can not use it for hexadecimal or octal numbers on the other hand %i is for integer that means any integer it can be decimal, hexadecimal or octal
20th Sep 2020, 7:30 PM
Ruba Kh
Ruba Kh - avatar
+ 2
.. Thanks to all, I understood 😊
21st Sep 2020, 1:38 AM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
rupali You can also use %i for int by the way,and %x for hex and %o for octal values! Hope this helped :)
20th Sep 2020, 7:26 PM
RuntimeERROR
RuntimeERROR - avatar
+ 1
As Ruba Kh stated, %i and %d is different. Precisely, they are different in scanf but not in printf.
20th Sep 2020, 10:33 PM
LastSecond959
LastSecond959 - avatar