0
Can somebody please explain the following C snippet?
4 Réponses
+ 6
printf("%d\n",printf("%d",printf("%d",a)));
When you see a nested function call like this, begin from the inner most call working your way outwards to the outer most call.
* printf function on success returns the total number of characters written (http://www.cplusplus.com/reference/cstdio/printf/).
* Inner call
printf("%d", a); // a = 43
This prints '43' and returns 2 (number of characters used to print '43')
* Middle call
printf("%d", 2); // 2 is return value from inner most call above
This prints '2' and returns 1 (number of characters used to print '2')
* Outer call
printf("%d\n", 1); // 1 is return value from middle call above
This prints '1' and returns 1 (number of characters used to print '1')
Hth, cmiiw
+ 2
++༒«ᵛ ⁱ ⁿ ᵃ ʸ ᵃ ᵏ»༒++
I was guessing it came from a challenge bro 😂
+ 1
No this one's from a book called coding for interviews, the answer is already given but with no proper explanation.