Can anybody tell me y this happening in c language | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anybody tell me y this happening in c language

int main(){ short int a =5; printf("%d"+1,a); getch(); return 0; } this code only prints d explain me why.... not even the value of a that is 5

2nd Sep 2017, 5:08 AM
Manjit Kumar
Manjit Kumar - avatar
10 Answers
+ 4
Here is a example created by modifying the code https://code.sololearn.com/cQ6C6WeR099N/?ref=app
2nd Sep 2017, 5:44 AM
Manual
Manual - avatar
+ 4
"%d" is of type char*, doing "%d"[1] is 'd' it is also equivalent to *("%d"+1) so "%d"+1 is the address of 'd'
2nd Sep 2017, 10:16 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 2
thanks
2nd Sep 2017, 10:19 AM
Manjit Kumar
Manjit Kumar - avatar
+ 2
oh.... nice... thanks u guys are awesome
2nd Sep 2017, 10:24 AM
Manjit Kumar
Manjit Kumar - avatar
+ 2
Your are welcomed ! :)
2nd Sep 2017, 10:27 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
and what is the difference between %d and %*d
2nd Sep 2017, 10:20 AM
Manjit Kumar
Manjit Kumar - avatar
+ 1
It has meaning for scanf only Adding the * means that the %d will not be read but needs to be here
2nd Sep 2017, 10:22 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
😂😂😂
2nd Sep 2017, 2:51 PM
Manjit Kumar
Manjit Kumar - avatar
0
i did +2 printed POSIX +45 printed c +36 printed 6c 😁😂😂😂
2nd Sep 2017, 11:15 AM
sayan chandra
sayan chandra - avatar
0
😉😂😂😂😂 +21 printed--> ng : : erase
2nd Sep 2017, 11:17 AM
sayan chandra
sayan chandra - avatar