+ 1

Can anyone explain how strchr works in C?

https://code.sololearn.com/cNXYjgRSaRBs/?ref=app Why do we put b-a+1 to print the current position of char in the string? Please explain the logic

21st Jul 2021, 2:06 PM
Srinath
2 Answers
+ 2
NotAPythonNinja oh now I get it, thanks!
21st Jul 2021, 4:09 PM
Srinath
+ 1
NotAPythonNinja thanks for answering but I'm not able to get why b-a will give me the index of the char? I get it, b returns the pointer to the char, and a stores the given string, but how does b-a exactly give me the index, can you please explain this.
21st Jul 2021, 3:57 PM
Srinath