Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to understand Atoi function - *string - '0'

Tags:

c

string

atoi

What exactly does the below statement do?

const char *string
*string - '0'

Thanks!

like image 551
Ava Avatar asked May 19 '26 20:05

Ava


1 Answers

It subtracts the value of the character '0' from the character pointed to by string, turning it into a numerical value. So for example the character '9' will be turned into the integer 9.

like image 59
Ry- Avatar answered May 22 '26 11:05

Ry-



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!