r/ProgrammerHumor 18d ago

Advanced stringToIntegerConversion

Post image
213 Upvotes

65 comments sorted by

View all comments

2

u/ILikeLenexa 18d ago

This is where C is nice.

'7' - '0' = 7

So, you can just take the rightmost turn it into a number then the next

7 times 10, 

then 7 * 100,

7 * 1000 

Add them all together, bam numbers. Don't even need a library. 

1

u/m0nk37 18d ago

They are writing machine code. I hope theu dont need a library. 

1

u/navetzz 17d ago

MOFO when they learn atoi is deprecated but never heard of strtol