+ 1

Sum of char in a int

Saw that code in a challenge (and I messed up). The output is "yo", and I have no idea of how it works. Someone could me explain? https://code.sololearn.com/cBzC2RJb2ODi/?ref=app

5th Nov 2017, 6:10 PM
Lucas Costa
Lucas Costa - avatar
2 Antworten
+ 2
I've commented out the code you provided, braking it into small steps. Take a look ask if any particular step isn't clear. https://code.sololearn.com/cuIykdknxlb4/?ref=app UPDATE: Forgot to mention one important thing. x86 platform is little endian, so the least significant byte is stored first. So our integer 00006f79 is read backwards in the string, like 796f0000.
5th Nov 2017, 7:04 PM
deFault
0
Amazing! I would never figure out what's going on... Had to learn some more to understand the explanation, and now I got it. Thank you so much!
6th Nov 2017, 10:10 AM
Lucas Costa
Lucas Costa - avatar